PHP mysqli_errno() Function

PHP mysqli_errno() function is used to get the error code for the most recent function call.

Syntax

int mysqli_errno(connection);

mysqli_errno() Function Parameter

ParameterDescription
connection :Required parameter. The MySQL connection to be used

mysqli_errno() Function Return Value

Return Values :An error code for the last call, if it failed. 0 means no error occurred.

mysqli_errno() Function Example

<?php
$con = mysqli_errnot("localhost","user","password","db");

if (mysqli_connect_errno())
{
	echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

if (!mysqli_query($con, "SELECT * FROM employee")) {
    echo "Error Code: " . mysqli_errno($con);
}

mysqli_close($con);
?>