douwen8118 2015-10-14 01:55
浏览 645

Mysqli中的警告消息:mysqli_stmt_bind_param()期望参数1为mysqli_stmt,给定布尔值? [重复]

I am using this code and i try to run it but it shows this error and try to fix it but i don't know how? Can anyone help me? :

Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in /home/u330779411/public_html/Register.php on line 10

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in /home/u330779411/public_html/Register.php on line 11

Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, boolean given in /home/u330779411/public_html/Register.php on line 13

Here is my code:

$name = $_POST['name'];
$matric_number = $_POST['matric_number'];
$username = $_POST['username'];
$password = $_POST['password'];

$statement = mysqli_prepare($con, "INSERT INTO Users (name, matric_number, username, password) VALUES (?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "siss", $name, $matric_number, $username, $password);
mysqli_stmt_execute($statement);

mysqli_stmt_close($statement);

mysqli_close($con);

Is it

</div>
  • 写回答

1条回答 默认 最新

  • donglin4636 2015-10-14 04:49
    关注

    According to the PHP Docs:

    mysqli_prepare() returns a statement object or FALSE if an error occurred.

    Since your warning states that a boolean was given, it is likely that an error occurred. I would suggest doing var_dump($statement) as @Dagon suggested to check if $statement is set to false.

    You might also want to check $con. I am assuming that you omitted that part and that you initialized it properly earlier in the code, but make sure you are checking for mysqli_connect_error() as well.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度