返回上次执行命令的错误列表(如果有):
<?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();
}
// Perform a query, check for error
if (!$mysqli -> query("INSERT INTO Persons (FirstName) VALUES ('Glenn')")) {
print_r($mysqli -> error_list);
}
$mysqli -> close();
?>
查看底部的程序样式示例。
error_list / mysqli_error_list() 函数返回最后执行的命令中的错误列表(如果有)。
$mysqli -> error_list
mysqli_error_list(
connection)
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
返回值: | 以关联数组的形式返回错误列表;包含 errno(错误代码)、error(错误文本)和 sqlstate |
---|---|
PHP 版本: | 5.4+ |
返回上次执行命令的错误列表(如果有):
<?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();
}
// 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);
?>
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!