Why Does \'Number of Bind Variables Doesn\'t Match Number of Fields in Prepared Statement\' Error Occur During INSERT Queries?

Mary-Kate Olsen
Release: 2024-10-31 04:12:02
Original
473 people have browsed it

 Why Does

Number of Bind Variables Doesn't Match Number of Fields in Prepared Statement while Inserting Data

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
Copy after login

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>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!