ID: 17118 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Closed Bug Type: Documentation problem PHP Version: 4.2.0 New Comment:
This bug has been fixed in CVS. You can grab a snapshot of the CVS version at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2002-05-10 04:35:25] [EMAIL PROTECTED] Expected behaviour, making it a docu prob. ------------------------------------------------------------------------ [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 -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php