|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-05-10 04:35 UTC] sander@php.net
[2002-07-01 18:20 UTC] jan@php.net
[2020-02-07 06:12 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 12:00:01 2025 UTC |
when more than one link is opened (to different db) in a php script, if mysql_error() is called without the optional link-id parameter it returns the error status relative to the last opened link whereas documentation states it should be about the last mysql_*() function call. So far it could be just a documentation problem (not clear enough) yet I'd expect mysql_error() to be smart enough to identify the link used by the most recent mysql_*() function rather just than picking the last created one. Obviously the same applies for mysql_errno() doc extract for mysql_error(): -------------------- Returns the error text from the last MySQL function, or '' (the empty string) if no error occurred. [...] Note that this function only returns the error text 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. Script ---- Here is a simple script to play with to view what I probably made less understandable by writing... Usage: test.tab1 and guestbook.book db's and tables must be there, the no_*such_table's table should generate an error... altering the order of connections changes the output as well. <? print "\nDB1\n"; $db1 = mysql_connect("localhost", "user", "user"); print mysql_error(); mysql_select_db("test"); print mysql_error(); print "\nDB2\n"; $db2 = mysql_connect("localhost", "guest", "guest"); print mysql_error(); mysql_select_db("guestbook"); print mysql_error(); print "\nQUERY1.1\n"; mysql_query("select * from tab1", $db1); print mysql_error(); print "\nQUERY1.2\n"; mysql_query("select * from no_1such_table", $db1); print mysql_error(); print "\nQUERY2.1\n"; mysql_query("select * from book", $db2); print mysql_error(); print "\nQUERY2.2\n"; mysql_query("select * from no_2such_table", $db2); print mysql_error(); print "\nQUERY1.1\n"; mysql_query("select * from tab1", $db1); print mysql_error(); print "\nQUERY1.2\n"; mysql_query("select * from no_3such_table", $db1); print mysql_error(); ?>