INSERT - 绑定变量的数量与准备好的语句中的字段数量不匹配

2021-12-25 00:00:00 insert php mysqli

我得到:

警告:mysqli_stmt::bind_result():绑定变量的数量没有匹配准备好的语句中的字段数E:XAMPPhtdocsaccountlibegister.php 第 73 行

Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in E:XAMPPhtdocsaccountlibegister.php on line 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;
} 

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

I can't understand, why this happens every time, what is wrong in my code snippet?

推荐答案

您正在尝试对未返回任何结果的语句进行bind_result.

You are attempting to bind_result on a statement that is not returning any results.

删除此行.<代码>$stmt ->bind_result($user, $pw);

相关文章