Ask Your Question

Revision history [back]

To show errors in mysqli_query, the following method can be used:

Step 1: Set the error reporting to maximum by adding the following code at the beginning of the PHP file:

errorreporting(EALL); iniset('displayerrors', 1);

Step 2: After executing the mysqliquery function, use the mysqlierror function to display any errors that may have occurred.

For example:

$query = "SELECT * FROM users"; $result = mysqli_query($connection, $query);

if (!$result) { die('Query Failed: ' . mysqli_error($connection)); }

This will display any errors that occurred during the execution of the mysqli_query function.