Home > Article > Backend Development > Why Does \"Number of Bind Variables Doesn\'t Match Number of Fields in Prepared Statement\" Error Occur During INSERT Queries?
When attempting to insert data into a database using PHP's mysqli extension, you may encounter the following error:
Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in E:\XAMPP\htdocs\account\lib\register.php on line 73
This error occurs when you specify a bind variable for each field in the INSERT query, but the query does not return any results. To resolve this issue, you need to remove the line that binds the results:
<code class="php">$stmt->bind_result($user, $pw);</code>
The modified code snippet would look like this:
<code class="php">$conn->prepare("INSERT INTO login(user, pass) VALUES(?, ?)"); $stmt->bind_param("ss", $user, $pw); $stmt->execute();</code>
The above is the detailed content of Why Does \"Number of Bind Variables Doesn\'t Match Number of Fields in Prepared Statement\" Error Occur During INSERT Queries?. For more information, please follow other related articles on the PHP Chinese website!