Multiple MySQL pointers
Eric Jensen
eric at emstraffic.com
Wed Feb 2 09:45:47 MST 2005
Had a huge database problem yesterday, we are trying to merge two
databases that are nearly identical. Here is how I have my pointers setup:
//connects to new merge-ready database
$db = mysql_connect("localhost", "user1", "********") or die(mysql_error());
mysql_select_db("db_one", $db) or die(mysql_error($db));
//connects to first database
$db_sm = mysql_connect('localhost', 'user1', '*******') or
die(mysql_error());
mysql_select_db("db_two", $db_sm) or die(mysql_error($db_sm));
//connect to second database
$db_ems = mysql_connect('outside_host', 'user2', '******') or
die(mysql_error());
mysql_select_db("db_two", $db_ems) or die(mysql_error($db_ems));
Problem we ran into was even though all the MySQL commands were using
specific pointers (I.E. mysql_query($sql, $db)) the first pointer's
($db) database was changed from "db_one" to "db_two". Later with some
experimenting it turns out that having the same login is what caused
that. As soon as I changed the first pointer to a different user it
worked as intended:
//connects to new merge-ready database
$db = mysql_connect("localhost", "new_user", "********") or
die(mysql_error());
mysql_select_db("db_one", $db) or die(mysql_error($db));
Anybody heard of this problem or can explain why? But more importantly
for now, anybody know a MySQL command that will allow me to double check
what database I'm currently using?
Eric
More information about the PLUG
mailing list