Page 1 of 1

using link identifier with 2 DBs

Posted: Tue Apr 21, 2009 5:31 am
by eskio
Hi,

I my form I populate 2 list boxes from different 2 databases.To distinhuish them I use a link identifier in

Code: Select all

mysql_query($query, $link1)
and

Code: Select all

mysql_query($query, $link2)
.

Code: Select all

$link1 = @mysql_connect("localhost", "xxxx", "xxxxx");mysql_select_db("db1")
$link2 = @mysql_connect("localhost", "xxxx", "xxxxx");mysql_select_db("db2")
 
As you can see $link1 and $link2 are the same.

My question is to use a link identifer, the hostname of the databases should be different? because in the script refers only to the last opened database.

Re: using link identifier with 2 DBs

Posted: Tue Apr 21, 2009 12:10 pm
by Christopher
eskio wrote:My question is to use a link identifer, the hostname of the databases should be different? because in the script refers only to the last opened database.
With MySQL a link is to a MySQL server which can contain many databases. You should select the database before each query.

Code: Select all

mysql_select_db("db1", $link);
mysql_query($query, $link)

Re: using link identifier with 2 DBs

Posted: Wed Apr 22, 2009 4:53 am
by eskio
Thanks