I seem to go back and forth on this, sometimes it works for me, often it doesn't and I can't figure out how/why I can get it to work sometimes, and at other times it won't.
I have 5 databases, and need to grab data from each of them during a maintenance routine. For each of the databases, I have an external file which contains all the db connection code which I include in my page.
The includes look like this
$SGcon = mysql_connect("localhost","root",""); if (!$SGcon) { die('Could not connect: ' . mysql_error()); } mysql_select_db("sGopen", $SGcon);
For each database I provide a different varaible, so the next database will be
$PTcon = mysql_connect("localhost","root",""); if (!$PTcon) { die('Could not connect: ' . mysql_error()); } mysql_select_db("pTsecond", $PTcon);
Then when i call my query, I use
mysql_query($getQuery, $PTcon); mysql_query($secondQuery, $SGcon);
The problem I'm running into is that I'm not getting the correct database used for the query , it seems my script is using the databases which was added to the page last.
Is there a better way for me to switch the database connection to be used?
There is lots of back and forth between the databases as I'm comparing data from one db to data in another, so i'm trying to be efficient with this as well.
Thanks Pete