[英]PHP mysqli prepare statement bind_param boolean error
Testing the statement from all side, but failed to find a solution for it. 从各个方面测试该语句,但未能找到解决方案。
// Insert the new user into the database
if( $insert_stmt = $mysqli->prepare("INSERT INTO client (username, email,
password, reg_ip, salt, country, ref_id, pin, ref_by, ref_by_2) VALUES ( ?,
?, ?, ?, ?, ?, ?, ?, ?, ?)")){
$insert_stmt->bind_param("ssssssssii", $username, $email, $pass_2,
$reg_ip, $random_salt, $countryname, $ref_code, $hashed_pin, $user_id3,
$user_id4);
$insert_stmt->execute();
This never executes or gets inside the if statement. 这永远不会执行或进入if语句中。
I debugged it by removing the if
part, that shows bind_param()
is boolean error. 我通过删除
if
部分来调试它,该部分显示bind_param()
是布尔错误。
$insert_stmt = $mysqli->prepare("INSERT INTO client (username, email,
password, reg_ip, salt, country, ref_id, pin, ref_by, ref_by_2) VALUES ( ?,
?, ?, ?, ?, ?, ?, ?, ?, ?)");
$insert_stmt->bind_param("ssssssssii", $username, $email, $pass_2, $reg_ip,
$random_salt, $countryname, $ref_code, $hashed_pin, $user_id3, $user_id4);
if($insert_stmt->execute()){
Fatal error: Call to a member function bind_param() on boolean
致命错误:在布尔值上调用成员函数bind_param()
I have done following test: 我已经完成以下测试:
Then where is the mistake? 那错误在哪里呢?
I figure it out. 我知道了。
Solution: It was not working because of the previous prepare statement $stmt_aff
connection was not closed. 解决方案:由于先前的prepare语句
$stmt_aff
连接未关闭,因此无法正常工作。 Once I closed it. 一旦我关闭它。 Next Prepare statement
$insert_stmt
started working. 下一步Prepare语句
$insert_stmt
开始工作。
A good lesson learned why bind_param
boolean error get produced if there are multiple prepare statement on the same page. 一个很好的经验教训是,如果同一页面上有多个prepare语句 ,为什么会产生
bind_param
布尔错误。
$stmt_aff->close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.