經過消毒和驗證後,可以正常工作。我試圖將數據插入到我的數據庫,但它口口聲聲說錯誤:「對不起,我們不能夠正確地爲您註冊...筆芯形式」無法使用PDO將數據插入到數據庫中
$qry = "INSERT INTO users (email, firstName, surname, userName, password, userDOB) values (?, ?, ?, ?, ?, ?)";
$q = $conn->prepare($qry) or die("ERROR: " . implode(":", $conn->errorInfo()));
$q->bindParam(1, $email);
$q->bindParam(2, $name);
$q->bindParam(3, $surname);
$q->bindParam(4, $username);
$q->bindParam(5, $password);
$q->bindParam(6, $userDOB);
$q->execute();
if(!$q->execute()) {
echo "<h1> Sorry, we were not able to sign you up... Refill the form properly </h1>";
}
else {
echo "<h1> Congratulations, $name ! You have been successfully signed up! </h1>";
}
任何幫助,這將使這項工作將不勝感激。
有沒有錯誤?你應該趕上PDO例外,以獲得更詳細的錯誤報告 –
http://stackoverflow.com/questions/3726505/how-to-squeeze-error-message-out-of-pdo –
做一些像'.. 。} else {die($ conn :: errorInfo); }'所以DB可以告訴你錯誤是什麼。固定的消息可以顯示給最終用戶,但是在調試時,除非它們也包含問題的實際細節,否則不要使用它們。 –