0
我收到2個錯誤在下面我的代碼:錯誤和警告出現在我的PHP/mysqli的
警告:mysqli的::製備()[mysqli.prepare]:(21S01/1136):柱計數沒有按「T匹配值計數在...行1上線115
致命錯誤:調用一個成員函數bind_param()在...非對象上線119
我使用的mysqli和php代碼。爲了解決這些錯誤,我需要做些什麼?
CODE:
$insertsql = "
INSERT INTO Teacher
(TeacherForename, TeacherSurname, TeacherEmail, TeacherAlias, TeacherUsername, TeacherPassword, Code)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?)
";
if (!$insert = $mysqli->prepare($insertsql)) {
// Handle errors with prepare operation here
}
$insert->bind_param("sssssss", $getfirstname, $getsurname,
$getemail, $getid, $getuser,
$teacherpassword, $code);
$insert->execute();
if ($insert->errno) {
// Handle query error here
}
$insert->close();
你有7個參數,在VALUES中有8個?刪除其中的一個'?',看看是否會使兩條消息都消失...... – andrewsi
@andrewsi我以爲我刪除了?但我可以清楚地看到我沒有。對不起,感謝您的評論:) – user1394925
@jprofitt - 這就是mysqli如何處理綁定參數 - http://php.net/manual/en/mysqli-stmt.bind-param.php – andrewsi