PHP mysqli_errno() Function

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


int mysqli_errno(connection);

mysqli_errno() Function Parameter

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

$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);