Ronbo51 Posted 9 hours ago Share Posted 9 hours ago (edited) I wrote a php script to update information in an mysqli database table and and am getting the error: The number of variables must match the number of parameters in a prepared statement. This is the code snippet with the error line in bold red. I don't see anything wrong with it but hopefully some of you sharp eyed people can help me. include "churchdb_data.php"; $con=mysqli_connect('localhost',$username,$password,$database); if (mysqli_connect_errno()) { die ("Failed to connect to MySQL: " . mysqli_connect_error()); } $sql = "UPDATE missionaries SET ID=?, missionary=?, active=?, country=?, city=?, state=?, zip=?, street=?, phone=?,email=?, website=?, facebook=?, photo=? WHERE ID=?"; $stmt = $con->prepare($sql); $stmt->bind_param("issssssssssss", $id, $missionary,$active,$country,$city,$state,$zip,$street,$phone,$email,$website,$facebook,$photo); if ($stmt->execute()) { echo "Record updated successfully!"; } else { echo "Error updating record: " . $stmt->error; } $stmt->close(); $con->close(); ?> Edited 8 hours ago by requinix edited title Quote Link to comment https://forums.phpfreaks.com/topic/329968-the-number-of-variables-must-match-the-number-of-parameters-in-a-prepared-statement/ Share on other sites More sharing options...
requinix Posted 8 hours ago Share Posted 8 hours ago You forgot the variable for the "WHERE ID=?" at the end of the query. And are you sure you really mean to try to update the ID? That would be weird... Quote Link to comment https://forums.phpfreaks.com/topic/329968-the-number-of-variables-must-match-the-number-of-parameters-in-a-prepared-statement/#findComment-1657490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.