October 27, 2024
Chicago 12, Melborne City, USA
PHP

Why doesn't PHP show my custom error message when mysqli_connect fails?


This is the code:

$query = "SELECT * FROM amz WHERE asin = '$asin' LIMIT 1";
$q = mysqli_query($con, $query) or trigger_error(file_put_contents('wth_ama.txt', $query), E_USER_ERROR);

In the error docs I sometimes get this error:

Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''B07P8P6D7V'' LIMIT 1'

Why is trigger_error not creating the wth_ama.txt file?

And about the error, does it mean that asin literally contain "'B07P8P6D7V'" and not "B07P8P6D7V"? If yes then it actually shouldn’t happen.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video