PHP mysqli_errno() function is used to get the error code for the most recent function call.
Syntax
int mysqli_errno(connection);
Parameter | Description |
---|---|
connection : | Required parameter. The MySQL connection to be used |
Return Values : | An error code for the last call, if it failed. 0 means no error occurred. |
<?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); ?>