Example 1 — Check Whether Warnings Exist
After a query, print whether get_warnings found anything. Sample assumes no warnings.
<?php
$mysqli = mysqli_connect("localhost", "demo_user", "demo_pass", "app_db");
mysqli_query($mysqli, "SELECT 1");
$w = mysqli_get_warnings($mysqli);
echo $w === false ? "No warnings." : $w->message, PHP_EOL;
mysqli_close($mysqli); How It Works
- Run a simple SELECT that normally produces no warnings.
- mysqli_get_warnings() returns false when the list is empty.
- We print a clear message for the false case.
- Close the connection at the end.

