PDO insert help

Hey there,

My insert script was working then i think i screwed something up as it is not inserting the data any more


try{
$query = 'INSERT INTO members  SET
   email = :email,
   password = :password,
   nameFirst = :nameFirst,
   nameLast = :nameLast,
   farmName = :farmName,
   groupNum = :groupNum';

 $s = $dbconnect->prepare($query);

 $s->bindValue(':email', $email);
 $s->bindValue(':password', $password);
 $s->bindValue(':nameFirst', $nameFirst);
 $s->bindValue(':nameLast', $nameLast);
 $s->bindValue(':farmName', $farmName);
 $s->bindValue(':groupNum', $groupNum);

 $s->execute();
 header('Refresh: 5; url = http://ageasy.ca');
 echo 'Your account has been added you can now login!';
 echo 'You well now be redirected to the home page';
}

catch(PDOException $e)
	{
		echo 'there was an error inserting you account to the database: '.$e->getMessage();
	}

that’s the sql insert. And yes i know it could use the bindValues with an array. I get the “Your account has been added you can now login” meaning it thinks it has been successful, but then when i go look in PMA (PhpMyAdmin) the data is not showing up. And connection seems to be ok as i am not getting any errors connecting.

Thanks for the help in advance!

From memory TRY CATCH exception handlers don’t respond to true and false which is what $s->execute() would be doing, simply get rid of it and use an IF ELSE statement instead.

if ($s->execute()) {
    header('Refresh: 5; url = http://ageasy.ca');
    echo 'Your account has been added you can now login!';
    echo 'You well now be redirected to the home page';
} else {
    echo "\
PDOStatement::errorInfo():\
";
    $arr = $sth->errorInfo();
    print_r($arr);
}