(PHP 5, PHP 7)
mysqli::errno -- mysqli_errno — 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷玫拇锟斤拷锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷锟教伙拷锟斤拷锟�
锟斤拷锟斤拷锟斤拷锟斤拷锟絤ysqli锟斤拷锟斤拷锟斤拷锟矫诧拷锟斤拷锟侥达拷锟斤拷锟斤拷锟�.
锟酵伙拷锟剿达拷锟斤拷锟斤拷Mysqlerrmsg.h头锟侥硷拷锟斤拷锟叫筹拷, 锟斤拷锟斤拷舜锟斤拷锟斤拷锟斤拷mysqld_error.h锟斤拷锟叫筹拷. 锟斤拷mysql源锟斤拷址锟斤拷锟斤拷械锟�Docs/mysqld_error.txt锟斤拷锟斤拷苑锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷拇锟斤拷锟斤拷锟较拷痛锟斤拷锟斤拷.
锟斤拷锟揭伙拷蔚锟斤拷貌锟斤拷锟斤拷拇锟斤拷锟斤拷锟斤拷, 锟斤拷锟斤拷0锟斤拷锟斤拷没锟叫达拷锟斤拷锟斤拷.
Example #1 mysqli->errno example
锟斤拷锟斤拷锟斤拷锟斤拷锟�
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* 锟斤拷锟斤拷锟斤拷锟� */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if (!$mysqli->query("SET a=1")) {
printf("Errorcode: %d\n", $mysqli->errno);
}
/* 锟截憋拷锟斤拷锟斤拷 */
$mysqli->close();
?>
锟斤拷锟教伙拷锟斤拷锟�
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* 锟斤拷锟斤拷锟斤拷锟� */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if (!mysqli_query($link, "SET a=1")) {
printf("Errorcode: %d\n", mysqli_errno($link));
}
/* 锟截憋拷锟斤拷锟斤拷 */
mysqli_close($link);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
Errorcode: 1193