PHP mysqli_error_list() 函数

PHP 教程 · 2019-01-27 19:42:03

实例

返回最近调用函数的最后一个错误代码:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:CODERCTO 
$con=mysqli_connect("localhost","root","123456","CODERCTO"); 
if (
mysqli_connect_errno($con)) 

    echo 
"连接 MySQL 失败: " mysqli_connect_error(); 


// 执行查询,检查错误
if (!mysqli_query($con,"INSERT INTO websites (name) VALUES ('码农教程')"))
{
    
print_r(mysqli_error_list($con));
}

mysqli_close($con);
?>

定义和用法

mysqli_error_list() 函数返回最近调用函数的错误列表。

语法

mysqli_error_list(connection);

参数 描述
connection 必需。规定要使用的 MySQL 连接。

技术细节

返回值: 返回错误列表。每个错误都是一个带有 errno(错误代码)、error(错误文本)和 sqlstate 的关联数组。
PHP 版本: 5.4+

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Algorithms Illuminated (Part 2)

Algorithms Illuminated (Part 2)

Tim Roughgarden / Soundlikeyourself Publishing, LLC / 2018-8-5 / USD 17.99

Algorithms are the heart and soul of computer science. Their applications range from network routing and computational genomics to public-key cryptography and machine learning. Studying algorithms can......一起来看看 《Algorithms Illuminated (Part 2)》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具