1
我有一段代码,使用mysqli和php将数据插入到数据库中。问题是,我得到一个致命的错误,声明:致命错误:无法通过参考传递参数2在线116插入时mysqli代码中的致命错误
为什么会出现此错误,我该如何解决错误?
下面是代码:
if ($numrows == 0){
$teacherpassword = md5(md5("j3Jf92".$teacherpassword."D203djS"));
$code = md5(rand());
$insertsql = "
INSERT INTO Teacher
(TeacherId, TeacherForename, TeacherSurname, TeacherEmail, TeacherAlias, TeacherUsername, TeacherPassword, Active, Code)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?)
";
if (!$insert = $mysqli->prepare($insertsql)) {
// Handle errors with prepare operation here
}
$insert->bind_param("sssssssss", '', $getfirstname, $getsurname,
$getemail, $getid, $getuser,
$teacherpassword, '0', $code);
$insert->execute();
if ($insert->errno) {
// Handle query error here
}
$insert->close();
如果您只是将一个空白字符串传递给'TeacherID',为什么不把它完全删除? – andrewsi