Forum Moderators: coopster
I have two database servers:
1. phpMyAdmin 2.4.0 and MySQL 3.23.58
2. phpMyAdmin 2.6.1-rc1 and MySQL 4.0.23
Both of them have a table called 'reservations' which I need to query lots of times to produce some results (I am creating some filters...anyway). I am trying to connect to the database as ussual, using a seperate script looking like this:
<?@ $db_conn = mysql_connect('localhost', 'usrname', 'password');mysql_select_db('reservations', $db_conn);?>
I have one problem and one question...
1. By using this code for connecting I can only connect to the 2nd server (2. phpMyAdmin 2.6.1-rc1 and MySQL 4.0.23)..the older server produces error messages...do I need to change my syntax to connect?
2. If I am finally able to connect to both server...can I query them both using a single query?
(both of them have table called reservations)...
example query:
$query50 = "select count(idc) as idc from reservations";
$result50 = mysql_query($query50);
$res=mysql_fetch_assoc($result50);
$resID = $res['idc'];
echo $resID;
..so if I am connected to both databases and try to count reservations table from both will it work?
any ideas would be appreciated...
thx in advance..
omoutop
$db_conn1 = mysql_connect('localhost', 'usrname', 'password');mysql_select_db('DATABASE1', $db_conn1);
$db_conn2 = mysql_connect('localhost', 'usrname', 'password');mysql_select_db('DATABASE2', $db_conn2);
and when you send a query you state what connection to use:
This one makes a query to the first DB
$result50 = mysql_query($query50, $db_conn1);
While this one to second
$result50 = mysql_query($query50, $db_conn2);
Hope this helps
<?
$db_conn1 = mysql_connect('localhost', 'username1', 'pass1');mysql_select_db('reservations', $db_conn1);
$db_conn2 = mysql_connect('#*$!.xxx.xx.xx', 'username2', 'pass2');mysql_select_db('reservations', $db_conn2);
?>
In the browser I get:
//////////////////////////////////////
Warning: mysql_connect(): Lost connection to MySQL server during query in /home/sites/site254/web/nikos/reservations/dbconnect.php on line 3
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/sites/site254/web/nikos/reservations/dbconnect.php on line 3
Total records in Database are : 90910
Total unique Email Addresses are : 41209
////////////////////////////////////////
which means that I can not connect to the oldest database...I might need another way (syntax) to connect to the (phpMyAdmin 2.4.0 and MySQL 3.23.58) database...
to see if it's problem with establishing a connection or with a query.
I also noticed you said
Both of them have a table called 'reservations'.