MySQLi - Errno
语法
int mysqli_errno ( mysqli $link )
定义和用法
它返回最近函数调用的错误代码。
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); exit(); } if (!mysqli_query($conn, "SET a = 1")) { printf("Errorcode: %d ", mysqli_errno($conn)); } echo 'Success... ' . mysqli_get_host_info($conn) . " "; mysqli_dump_debug_info($conn); mysqli_autocommit($conn,FALSE); mysqli_query($conn,"INSERT INTO tutorials_auto (id,name) VALUES (10,'sai')"); mysqli_commit($conn); mysqli_close($conn); ?>
上述代码的示例输出应该是这样的 −
Errorcode: 1193 Success... localhost:3306 via TCP/IP
在上面的示例中,如果您提供了错误的身份验证详细信息,它将返回最近函数的错误代码