In PHP, mysqli_warning_count() returns how many warnings the last MySQLi operation produced on the connection.
Warnings are softer than errors — the statement may still succeed while something looks suspicious (truncated data, unsafe settings, and similar). Pair this count with mysqli_get_warnings() to read each warning, and with sqlstate()/error() for hard failures.
Syntax
Call mysqli_warning_count() with the values you need. Start with this line.
PHP
$n = mysqli_warning_count($mysql);
Call
What it does
mysqli_warning_count($link)
Returns the number of warnings from the last operation.
$mysqli->warning_count
Object-oriented property form.
mysqli_get_warnings($link)
Fetches the warning list when the count is greater than zero.
A zero count means no warnings for the last command. OO style usually reads the warning_count property. Checking warnings is part of careful diagnostics alongside errno, error, and sqlstate.
Library declarations
PHP
mysqli_warning_count(mysqli $mysql): int
Parameters
Parameter
Description
mysql
Required. Procedural style only: a mysqli connection.
Return Value
Return Value
Description
int
The number of warnings generated by the previous operation (0 if none).