The mysqli_errno() function returns a list of errors for the most recent function call.
PHP mysqli_error_list() Function has the following syntax.
mysqli_error_list(connection);
Parameter | is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
A list of errors, each as an associative array containing the errno, error, and sqlstate.
<?php//from ww w .ja v a2s. c om
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Perform a query, check for error
if (!mysqli_query($con,"INSERT INTO Persons (FirstName) VALUES ('Jack')")){
print_r(mysqli_error_list($con));
}
mysqli_close($con);
?>