I am trying to connect to two databases simultaniously, and I am having issues. I have looked at previous threads about connecting to multiple dbs and have examined php.net on the issue, however, I still have an issue.
It appears that no matter what I do, if I attempt to open two databases at once, it only uses the last one opened. I am using the following code to connect:
//connection
$dbase['conn1'] = mysql_connect($db_config['conn1_host'], $db_config['conn1_user'], $db_config['conn1_pass']);
mysql_select_db($db_config['conn1_dbas'], $dbase['conn1']) or die (mysql_error());
$dbase['conn2'] = mysql_connect($db_config['conn2_host'], $db_config['conn2_user'], $db_config['conn2_pass']);
mysql_select_db($db_config['conn2_dbas'], $dbase['conn2']) or die (mysql_error());
//sample queries
$mysql_query = mysql_query($sql, $dbase['conn1']);
$mysql_query = mysql_query($sql, $dbase['conn2']);
The end result is that on both of those queries, php tries to connect to connection 2 every time. Therefor, the first query returns an error.
I thought at first that perhaps you couldn't store 2 connections in the same variable as an array, so I tried to replace the $dbase with $db_conn1 and $db_conn2. Same result.
Does anyone know what I'm doing wrong?