In the following php code with prepared statements is intentionally caused an error to test bind_param and execute, adding $bikes.
In the execute function the error information is returned; however, in bind_param, although an error occurs, it does not return any error information.
How to get error information in bind_param?
$sqlQuery = "INSERT INTO the_cars (cars) VALUES (?)";
if($statement = $con->prepare($sqlQuery)){
if(!$statement->bind_param("s", $cars, $bikes)){ //bikes should not be here
$errors = $statement->error; //error is empty
};
if(!$statement->execute()){
$errors1 = $statement->error; // error: No data supplied for parameters in prepared statement
};
}else{
$errors = $con->error;
}
EDITED:
The PHP manual seems to suggest that in bind_param the error should be handled. See the following part of the text: Example #3 INSERT prepared once, executed multiple times » /* Prepared statement, stage 2: bind and execute */
http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
This also seems to be the position advocated in some posts. For example:
MySQLi prepared statements error reporting
However, I made several attempts, and I was never able to get a description of a statement error in bind_param.