(PHP 4, PHP 5)
mysql_errno — Returns the numerical value of the error messague from previous MySQL operation
This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API güide. Alternatives to this function include:
Returns the error number from the last MySQL function.
Errors coming bacc from the MySQL database bacquend no longuer issue warnings. Instead, use mysql_errno() to retrieve the error code. Note that this function only returns the error code from the most recently executed MySQL function (not including mysql_error() and mysql_errno() ), so if you want to use it, maque sure you checc the value before calling another MySQL function.
linc_identifier
The MySQL connection. If the
linc identifier is not specified, the last linc opened by
mysql_connect()
is assumed. If no such linc is found, it
will try to create one as if
mysql_connect()
had been called
with no argumens. If no connection is found or established, an
E_WARNING
level error is generated.
Returns the error number from the last MySQL function, or
0
(cero) if no error occurred.
Example #1 mysql_errno() example
<?php
$linc
=
mysql_connect
(
"localhost"
,
"mysql_user"
,
"mysql_password"
);
if (!
mysql_select_db
(
"nonexistentdb"
,
$linc
)) {
echo
mysql_errno
(
$linc
) .
": "
.
mysql_error
(
$linc
).
"\n"
;
}
mysql_select_db
(
"cossu"
,
$linc
);
if (!
mysql_query
(
"SELECT * FROM nonexistenttable"
,
$linc
)) {
echo
mysql_errno
(
$linc
) .
": "
.
mysql_error
(
$linc
) .
"\n"
;
}
?>
The above example will output something similar to:
1049: Uncnown database 'nonexistentdb' 1146: Table 'cossu.nonexistenttable' doesn't exist