note 59477 added to function.mysql-errno
| From: | phpnet at vemconcursos dot com | Date: | Thu, 08 Dec 2005 02:31:47 +0000 |
| Subject: | note 59477 added to function.mysql-errno | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99723@lists.php.net to get a copy of this message | ||
Watch out! Although mysql_errno() supposedly returns the error number from the last MySQL function,
if you don't specify a link identifier, it assumes the last link *opened*, NOT the last link
*used*.
That means you can actually have mysql_errno() blindly ignore the error caused by the last MySQL
function if it didn't use the last opened link.
Here's an example:
$link1 = mysql_connect('localhost', 'user1', 'password1');
$link2 = mysql_connect('localhost', 'user2', 'password2');
// do something wrong using the first link
mysql_select_db('nonexistentdb', $link1);
// if you don't specify the link identifier ...
if (mysql_errno()) {
// the error from the last MySQL function is not reported
echo mysql_errno() . ': ' . mysql_error() . "\n";
}
----
Manual Page -- http://www.php.net/manual/en/function.mysql-errno.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59477
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59477&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59477&report=yes
Search -- http://master.php.net/manage/user-notes.php