array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.mysql-errno.php', 1 => 'mysql_errno', 2 => 'Returns the numerical value of the error message from previous MySQL operation', ), 'up' => array ( 0 => 'ref.mysql.php', 1 => 'MySQL Функції', ), 'prev' => array ( 0 => 'function.mysql-drop-db.php', 1 => 'mysql_drop_db', ), 'next' => array ( 0 => 'function.mysql-error.php', 1 => 'mysql_error', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mysql/functions/mysql-errno.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 4, PHP 5)
mysql_errno — Returns the numerical value of the error message from previous MySQL operation
Це розширення застаріле, починаючи з PHP 5.5.0, та вилучене з PHP 7.0.0. Натомість використовуються розширення MySQLi або PDO_MySQL. Докладніше описано у керівництві MySQL: вибір API. Цю функцію можна замінити на:
Returns the error number from the last MySQL function.
Errors coming back from the MySQL database backend no longer 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, make sure you check the value before calling another MySQL function.
link_identifier
З'єднання
MySQL. Якщо не задано, буде обрано останнє з'єднання, встановлене функцією
mysql_connect(). Якщо з'єднатися не вдалось, функція
спробує встановити нове, ніби викликавши функцію
mysql_connect() без параметрів. Якщо з'єднання не
вдалося знайти або встановити, буде виведено повідомлення рівня
E_WARNING
Returns the error number from the last MySQL function, or
0
(zero) if no error occurred.
Приклад #1 mysql_errno() example
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
if (!mysql_select_db("nonexistentdb", $link)) {
echo mysql_errno($link) . ": " . mysql_error($link). "\n";
}
mysql_select_db("kossu", $link);
if (!mysql_query("SELECT * FROM nonexistenttable", $link)) {
echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
}
?>
Поданий вище приклад виведе щось схоже на:
1049: Unknown database 'nonexistentdb' 1146: Table 'kossu.nonexistenttable' doesn't exist