
(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new mysqli(“localhost”, “my_user”, “my_password”, “world”); $mysqli->query(“SELECT 1/0, CAST(‘NULL’ AS UNSIGNED)”); if ($mysqli->warning_count > 0) { $warning = $mysqli->get_warnings(); if ($warning !== false) { do { printf(“Error number: %sn”, $warning->errno); printf(“Message: %sn”, $warning->message); } while ($warning->next()); } } (MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $link = mysqli_connect(“localhost”, “user”, “password”, “test”); mysqli_query($link, “SELECT 1/0, CAST(‘NULL’ AS UNSIGNED)”); if (mysqli_warning_count($link) > 0) { $warning = mysqli_get_warnings($link); if ($warning !== false) { do { printf(“Error number: %sn”, $warning->errno); printf(“Message: %sn”, $warning->message); } while ($warning->next()); } }
The above examples will output:
Error number: 1365 Message: Division by 0 Error number: 1292 Message: Truncated incorrect INTEGER value: ‘NULL’