我在下面的代码中收到2个错误:
警告:mysqli :: prepare()[mysqli.prepare] :( 21S01 / 1136):列数与第115行的第1行的值计数不匹配
致命错误:在第119行的...中的非对象上调用成员函数bind_param()
我正在使用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();
答案 0 :(得分:0)
SQL中有太多参数:
INSERT INTO Teacher
(TeacherForename, TeacherSurname, TeacherEmail, TeacherAlias, TeacherUsername,
TeacherPassword, Code)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?)
有7列和8个参数。