From: JULES at SITEPOINT dot COM Operating system: RH linux 2.4.18 PHP version: 4.3.0 PHP Bug Type: MySQL related Bug description: Simultaneous connections with same user/password do not work.
When making two simultaneous connections to a MySQL server using the same username / password combination, the MySQL link resource returned is the same. The upshot of this is that I am unable to use these 2 connections to simultaneously work with 2 different databases that happen to share one user/pass set. Put simply: If I call mysql_select_db() on one connection, it changes the selected DB on the other connection, too. The following code illustrates the sharing of the connection by executing a bogus query on one connection then calling mysql_error() on both connections. <? $conn1 = mysql_connect ("localhost", "sales", "xxxx"); $conn2 = mysql_connect ("localhost", "sales", "xxxx"); mysql_select_db("sales", $conn1); mysql_select_db("salesNEW", $conn2); mysql_query("SELECT blah FROM blah", $conn1); echo mysql_error($conn1)."<br />"; echo mysql_error($conn2); echo "<br /><br />"; echo $conn1."<br />"; echo $conn2; ?> The output is: Table 'salesNEW.blah' doesn't exist Table 'salesNEW.blah' doesn't exist Resource id #2 Resource id #2 Notice that I'm executing the broken query on $conn1. Yet the error message is returned on both $conn1 and $conn2. Also notice that the Resource id's are both 2, which easily explains this behavior. It gets more bizarre when I swap over to mysql_pconnect(). The output becomes: Table 'salesNEW.blah' doesn't exist Table 'salesNEW.blah' doesn't exist Resource id #2 Resource id #3 So the behaviour is the same, but PHP clearly thinks it has 2 seperate connections this time. To determine whether PHP or MySQL was causing this bug, I used 2 simultaneous instances of the mysql command line client and verified that it happily coped with the situation. -- Edit bug report at http://bugs.php.net/?id=22654&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22654&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22654&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22654&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22654&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22654&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22654&r=support Expected behavior: http://bugs.php.net/fix.php?id=22654&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22654&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22654&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22654&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22654&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22654&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22654&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22654&r=gnused