Current Location: Home> Function Categories> mysqli::$error_list

mysqli::$error_list

(mysqli_error_list) Returns the error list of the previous command executed
Name:mysqli::$error_list
Category:MySQLi
Programming Language:php
One-line Description:Returns the list of errors for the last function call.

Definition and usage

error_list / mysqli_error_list() function returns the error list (if any) of the last executed command.

Example

Example 1 - Object-Oriented Style

Returns the error list of the last command executed (if any):

 <?php
$mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ;

if ( $mysqli -> connect_errno ) {
  echo "Failed to connect to MySQL: " . $mysqli -> connect_error ;
  exit ( ) ;
}

// Execute the query and check for errors
if ( ! $mysqli -> query ( "INSERT INTO Persons (FirstName) VALUES ('Glenn')" ) ) {
  print_r ( $mysqli -> error_list ) ;
}

$mysqli -> close ( ) ;
?>

Example 2 - Procedural Style

Returns the error list of the last command executed (if any):

 <?php
$con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ;

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

// Execute the query and check for errors
if ( ! mysqli_query ( $con , "INSERT INTO Persons (FirstName) VALUES ('Glenn')" ) ) {
  print_r ( mysqli_error_list ( $con ) ) ;
}

mysqli_close ( $con ) ;
?>
Similar Functions
Popular Articles