Your MySQL and PHP code may be fully and logically thought-out. You may have even tested and verified it worked. But now you have this error:
"bind_param() expects parameter 1 to be resource, boolean given"
Your code probably looks something like this...
$db_link = new mysqli($hostname, $username, $password, $database);
$sql = "SELECT * FROM SomeTable WHERE id = ?";
$statement = $db_link->prepare($sql);
$statement->bind_param($_POST['id']);
How do you fix it? The problem is not with the bind_param() function, it's with the prepare() or the mysqli() functions!
If statement is a boolean, that means it is true or false, and in this case, false means that either mysqli() could not connect to the DB, or that prepare() had a problem.
If mysqli() has a problem, it could be a bad username/password combination, a networking issue, a bad db name, or something else. If prepare() has a problem, it could be a bad query, an unescaped term in the query, or something like that.
You can verify that mysqli() worked, by displaying its result and seeing that it's not false, and similarly with prepare().
No comments:
Post a Comment