Connection to Two databases simultaneously

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am connecting to two database in my index.php.

Here is how:
@ $db = mysql_connect("localhost", USERLOGIN, USERDBPASS);
 if (!$db)
 {  print "Error: Could not connect to database. Please try again later.";  exit; }
mysql_select_db(DATABASE);

@ $userdb = mysql_connect("localhost", USERLOGIN, USERDBPASS);
 if (!$userdb)
 {  print "Error: Could not connect to database. Please try again later.";  exit; }
mysql_select_db(USERDB);

$getaccount = "SELECT * FROM account WHERE visible=1";  //Account table is present in USERDB.
$result = mysql_query($getaccount);

$get = "SELECT * FROM useraccount";  //UserAccount table is present in DATABASE.
$result = mysql_query($get);

There is no problem with the connection. but I need to query tables in both databases. I know you need to use link identifiers, but have had no luck in getting it to work. Appreciate your help.

Thanks.
HarryG

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux