【问题标题】:INSERT - Number of bind variables doesn't match number of fields in prepared statement插入 - 绑定变量的数量与准备好的语句中的字段数量不匹配
【发布时间】:2023-03-26 07:30:02
【问题描述】:

我明白了:

警告:mysqli_stmt::bind_result():绑定变量的数量不 匹配准备好的语句中的字段数 E:\XAMPP\htdocs\account\lib\register.php 在第 73 行

当我使用这段代码时:

if($stmt = $conn -> prepare("INSERT INTO login(user, pass) VALUES(?, ?)")) {

  /* Bind parameters s - string, b - blob, i - int, etc */
  $stmt -> bind_param("ss", $user, $pw);

  /* Execute it */
  $stmt -> execute();

  /* Bind results */
  $stmt -> bind_result($user, $pw);

  /* Close statement */
  $stmt -> close();
  $userId = $conn->insert_id;
} 

我不明白,为什么每次都会发生这种情况,我的代码 sn-p 有什么问题?

【问题讨论】:

  • 您正在绑定 3 个参数 - 在您的声明中只有 2 个(“?”)
  • @niyou 不正确,第一个是类型列表
  • 第 73 行是哪一行?我不希望 INSERT 语句的结果,所以我怀疑它是 $stmt -> bind_result($user, $pw);
  • 你是对的 MB - 对不起

标签: php mysqli insert


【解决方案1】:

您正试图在未返回任何结果的语句上 bind_result

删除此行。 $stmt -> bind_result($user, $pw);

【讨论】:

    猜你喜欢
    • 2014-01-06
    • 2016-05-22
    • 2018-04-07
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多