PHP Tutorial - PHP mysqli_error_list() Function






Definition

The mysqli_errno() function returns a list of errors for the most recent function call.

Syntax

PHP mysqli_error_list() Function has the following syntax.

mysqli_error_list(connection);

Parameter

Parameteris RequiredDescription
connectionRequired.MySQL connection

Return

A list of errors, each as an associative array containing the errno, error, and sqlstate.

Example


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