|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-11-05 19:42 UTC] cnewbill at elementalrain dot com
[2001-11-20 18:42 UTC] mfischer@php.net
[2001-11-20 19:15 UTC] cnewbill@php.net
[2001-11-21 13:26 UTC] sniper@php.net
[2010-03-12 03:50 UTC] lovedone97 at hotmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
I need multiple connections to the same MySQL server to two different databases and mysql_select_db() is not honoring the resource_identifier, it is using the one of that last connection opened. //script <?php // test mysql_select_db with two active connections $conn1 = mysql_connect("localhost", "root" ,"#rain!"); if (!$conn1) { print "Could not connect to server one\n"; } else { if (!mysql_select_db("st2", $conn1)) print "Could not select DB on server one ".mysql_error($conn1)."\n"; } $conn2 = mysql_connect("localhost", "root" ,"#rain!"); if (!$conn2) { print "Could not connect to server two\n"; } else { if (!mysql_select_db("commercesys", $conn2)) print "Could not select DB on server two ".mysql_error($conn2)."\n"; } if (!mysql_query("select * from user", $conn1)) { print "Could not issue query to conn1 ".mysql_error($conn1)."\n"; } if (!mysql_query("select * from customer", $conn2)) { print "Could not issue query to conn2 ".mysql_error($conn2)."\n"; } ?> OUTPUT: Could not issue query to conn1 Table 'commercesys.user' doesn't exist If you flip the connect blocks you get: Could not issue query to conn2 Table 'st2.customer' doesn't exist I'll look at the source, but this is not too cool. -Chris