I'm pretty new in PHP coding, and I cannot find the error in the following code... could you help me please ?
Fatal error: Cannot use object of type PDOStatement as array in C:\wamp\www\membre\inscription_post.php on line 14 Call Stack # Time Memory Function Location 1 0.0006 682688 {main}( ) ..\inscription_post.php:0
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=test', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$mem = $bdd -> query('SELECT * FROM membres');
while ($data = $mem -> fetch())
{
if($mem['pseudo'] == $_POST['pseudo'])
{
echo "Pseudo existant";
}
else
{
$pass_hache = sha1($_POST['pass']);
$req = $bdd->prepare('INSERT INTO membres (pseudo, pass, email, date_inscription) VALUES(?, ?, ?, CURDATE())');
$req->execute(array($_POST['pseudo'], $pass_hache, $_POST['email']));
header('Location: inscription.php');
echo "Membre ajouté";
}
}
$mem -> closeCursor();
?>
membres
table structure is the following
id(=INT, primary key),
pseudo (VARCHAR(255)),
pass (VARCHAR(255)),
date_inscription (date)
Thank you for your help