|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-10-12 07:40 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 02:00:01 2025 UTC |
The function mysql_select_db() doesn't work as expected from the manual: "sets the current active database on the server that's associated with the specified link identifier." When I have two different link identifiers, with the same connexion data (host, user, password), and when I select two different databases for each link identifier, the first link identifier is linked the database of the second link identifier. I found this bug when working with several instances of the class "DB_Sql" of the phplib, linked to different databases, with the same "connexion data". I reproduced the bug with the following script: <? $host = "localhost"; $user = "root"; $pass = "not_real_pass"; $database1 = "Brasnah"; $database2 = "BrasnahBTracking"; /* first connection to the database */ $link_id1 = mysql_pconnect( $host, $user, $pass ); /* connection to the database 1 */ if( mysql_select_db( $database1 , $link_id1 ) ) { if( $r1 = mysql_query( "select * from Auth_User", $link_id1 ) ) { echo "$link_id1=>$r1<br>\n"; } } /* second connection to the database with the same data */ $link_id2 = mysql_pconnect( $host, $user, $pass ); /* connection to the database 2 */ if( mysql_select_db( $database2 , $link_id2 ) ) { if( $r2 = mysql_query( "select * from erttb_item ", $link_id2 ) ) { echo "$link_id2=>$r2<br>\n"; } } if( $r3 = mysql_query( "select * from Auth_User", $link_id1 ) ){ echo "$link_id1=>$r3<br>\n"; } else { echo mysql_errno( $link_id1 ).": ".mysql_error( $link_id1 )."<BR>"; } ?> which outputs: 1=>2 3=>4 1146: Table 'BrasnahBTracking.Auth_User' doesn't exist