mysqli_error_list()
实例
返回最近调用函数的错误列表:
<?php
$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 (‘Glenn‘)"))
{
print_r(mysqli_error_list($con));
}
mysqli_close($con);
?>
$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 (‘Glenn‘)"))
{
print_r(mysqli_error_list($con));
}
mysqli_close($con);
?>
定义和用法
mysqli_error_list() 函数返回最近调用函数的错误列表。
语法
mysqli_error_list(connection);
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
技术细节
返回值: | 返回错误列表。每个错误都是一个带有 errno(错误代码)、error(错误文本)和 sqlstate 的关联数组。 |
---|---|
PHP 版本: | 5.4+ |