PHP mysqli_error_list()Functions
Examples
Returns the last error code from the most recently called function:
<?php
// Assume database username: root, password: 123456, database: EXAMPLE
$con=mysqli_connect("localhost","root","123456","EXAMPLE");
if (mysqli_connect_errno($con))
{
echo "MySQL connection failed: ". mysqli_connect_error();
}
// Execute the query and check for errors
if (!mysqli_query($con,"INSERT INTO websites (name) VALUES ('Rookie Tutorial')"))
{
print_r(mysqli_error_list($con));
}
mysqli_close($con);
?>
// Assume database username: root, password: 123456, database: EXAMPLE
$con=mysqli_connect("localhost","root","123456","EXAMPLE");
if (mysqli_connect_errno($con))
{
echo "MySQL connection failed: ". mysqli_connect_error();
}
// Execute the query and check for errors
if (!mysqli_query($con,"INSERT INTO websites (name) VALUES ('Rookie Tutorial')"))
{
print_r(mysqli_error_list($con));
}
mysqli_close($con);
?>
Definition and Usage
The mysqli_error_list() function returns the error list from the most recently called function.
Syntax
mysqli_error_list(connection);
| Parameters | Description |
|---|---|
| connection | Required. Specifies the MySQL connection to use. |
Technical Details
| Return value: | Returns an error list. Each error is an associative array with errno (error code), error (error text), and sqlstate. |
|---|---|
| PHP Version: | 5.4+ |
PHP MySQLi Reference Manual Other Extensions