返回最近函数调用的最后一个错误描述(如果有):
<?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')")) {
echo("Error description: " . $mysqli -> error);
}
$mysqli -> close();
?>
查看底部的程序样式示例。
error / mysqli_error() 函数返回最近函数调用的最后一个错误描述(如果有)。
$mysqli -> error
mysqli_error(
connection)
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
返回值: | 返回带有错误描述的字符串。 "" 如果没有发生错误 |
---|---|
PHP 版本: | 5+ |
返回最近函数调用的最后一个错误描述(如果有):
<?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')")) {
echo("Error description: " . mysqli_error($con));
}
mysqli_close($con);
?>
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!