Women in Technology

Hear us Roar



Article:
  Using MySQL from PHP
Subject:   Using mysql from PHP
Date:   2007-08-14 03:53:45
From:   suamya
Hello,


In a single PHP code, I want to connect to two different hosts with totally different authentication information. Is it possible?


Right now snippet of my code looks something like this:
<?php
.....
$conn_1=mysql_connect('host1','user1','pass1');
$conn_2=mysql_connect{'host2','user2','pass2');
$db_list = mysql_list_dbs($conn_2);


while ($row = mysql_fetch_object($db_list)) {
echo $row->Database . "\n";
}
?>


However when I try to list all the databases in host2, it instead lists the database in host1.
host1 and host2 are different machines and the databases in each of them are entirely different.


I read that the new_link parameter might be used here but I couldnt figure out how to do that.


I am new to PHP...so any help would be great!!


-suamya.