ID: 17118 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open -Bug Type: MySQL related +Bug Type: Documentation problem PHP Version: 4.2.0 New Comment:
Expected behaviour, making it a docu prob. Previous Comments: ------------------------------------------------------------------------ [2002-05-09 09:44:01] [EMAIL PROTECTED] 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(); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17118&edit=1