Finding Errors in the Database

As you already know, in PHP, error display is enabled using the error_reporting function. This function, however, does not enable the display of errors made in the SQL query text.

To output SQL command errors, you should use the mysqli_error function, which must be added to every database query, like this:

php<?php
  $query = 'SELECT * FROM users';
  $res = mysqli_query($link, $query) or die(mysqli_error($link));
?>

For now, let's not delve into how this construct works. Just add it and, in case of an erroneous SQL query, you will see a message about it in the browser window.