Thread: 2 databases
View Single Post
  #2 (permalink)  
Old 05-15-2007, 10:57 PM
studiokraft studiokraft is offline
WebProWorld New Member
 

Join Date: Jun 2006
Location: NorthEast
Posts: 23
studiokraft RepRank 0
Default Re: 2 databases

Quote:
Originally Posted by jazzmatazz2005
how do i change this login script to check 2 databases.
Assuming that the databases exist on the same server, you should be able use mysql_db_query() instead of the combination of mysql_select_db() and mysql_query().

http://us.php.net/function.mysql-db-query

You should then be able to check the databases one at a time using two mysql_db_query() statements.

Code:
mysql_db_query("db1",$query);
mysql_db_query("db2",$query);
For multiple servers, its best to give each connection its own handle and refer to the handle when processing the query:

Code:
$handle_db1 = mysql_connect("localhost","myuser","apasswd");
$handle_db2 = mysql_connect("127.0.0.1","myuser","apasswd");
mysql_select_db("db1",$handle_db1);
mysql_select_db("db2",$handle_db2);
$query = "select * from test"; $which = $handle_db1;
mysql_query($query,$which);
__________________
~==================================~
Kim Kraft
StudioKraft
http://www.studiokraft.com/
~==================================~