Reputation: 1246
I am trying to catch the error that an unsuccessful bind statement result in, which is why I am deliberately not passing in the types to the mysqli_stmt_bind_param()
function. Please see the code snippet below
$email = '[email protected]';
$password = 'password';
if (!(mysqli_stmt_bind_param($stmt , '' , $email, $password))) {
echo "Binding parameters failed: (" . mysqli_stmt_errno($stmt) . ") " . mysqli_stmt_error($stmt) . "<br>";
}
However, the mysqli_stmt_errno
returns 0 and the mysqli_stmt_error()
returns an empty string.
PHP gives a warning saying
Warning: mysqli_stmt_bind_param(): Invalid type or no types specified in C:\wamp\www\test\database1.php on line 28
Why do I not get feedback from the database?
Upvotes: 0
Views: 191
Reputation: 1246
The bind parameters are sent along with the execute statement, and not before. The bind and execute happens in a single SQL statement, even though there are 2 PHP functions for it. Its only after the execute statement has run that the database is in a position to give feedback about an unsuccessful bind. Hope this helps anyone who might wonder regarding the same.
Upvotes: 0