I’m slightly new to PDO, i know how to select data perfectly fine, my problem is inserting.
$Finalize = $pdo->prepare("INSERT INTO `users` VALUES(`id`,:email,:hashedpassword,:firstname,:lastname,:gender,:bdaymonth,:bdayday,:bdayyear,'".time()."',:username)");
$Finalize->bindValue(':email', $email, PDO::PARAM_STR);
$Finalize->bindValue(':hashedpassword', $hashedPassword, PDO::PARAM_STR);
$Finalize->bindValue(':firstname', $first_name, PDO::PARAM_STR);
$Finalize->bindValue(':lastname', $last_name, PDO::PARAM_STR);
$Finalize->bindValue(':gender', $gender, PDO::PARAM_STR);
$Finalize->bindValue(':bdaymonth', $bday_month, PDO::PARAM_STR);
$Finalize->bindValue(':bdayday', $bday_day, PDO::PARAM_STR);
$Finalize->bindValue(':bdayyear', $bday_year, PDO::PARAM_STR);
$Finalize->bindValue(':bdayday', $username, PDO::PARAM_STR);
if($Finalize->execute() == false){
echo '6';
die;
}
What am I doing wrong? This script was just using mysql_query and working fine, so I don’t know what i did wrong.
You are twice binding values to the
':bdayday'parameter, and are not binding any value to the':username'parameter:By default, PDO does not output warnings or throw exceptions when an error occurs: you must instead manually inspect the return value of each function to see whether it succeeded and handle errors appropriately.
You can, however, modify this default behaviour.