返回最近调用函数的最后一个错误代码:
<?php // 假定数据库用户名:root,密码:123456,数据库:RUNOOB $con=mysqli_connect("localhost","root","123456","RUNOOB"); 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); ?>