About the prepared statement, theoretical, you will find out that your kwery is poorly formatted before sending the parameters. Therefore, you do not have to wonder if this is your request or the user data that is being listened to, you know it immediately.
About general queries, since mysqli synchronizes with MySQL5, while mysql_ does not support the old API until MYSQL 4, you will have the best error message, or at least the most descriptive one.
Alternatively, you can use the try \ catch syntax to detect mysql errors, and it is easier to handle exceptions instead of or die.... or if(mysql_error()) .
from the documentation you have:
<?php define("MYSQL_CONN_ERROR", "Unable to connect to database."); // Ensure reporting is setup correctly mysqli_report(MYSQLI_REPORT_STRICT); // Connect function for database access function connect($usr,$pw,$db,$host) { try { $mysqli = new mysqli($host,$usr,$pw,$db); $connected = true; } catch (mysqli_sql_exception $e) { throw $e; } } try { connect('username','password','database','host'); echo 'Connected to database'; } catch (Exception $e) { echo $e->errorMessage(); }
mysqli_report(MYSQLI_REPORT_STRICT) key function mysqli_report(MYSQLI_REPORT_STRICT) , according to the documentation:
MYSQLI_REPORT_STRICT
Throw a mysqli_sql_exception for errors instead of warnings.
there is also a / t mysqli_debug like eis.