Sometimes we need to connect to multiple databases with our PHP script. Try not to connect to too many different hosts, this can increase considerably the execution time of your script.
First, I create the 2 connection with 2 hosts:

$user1 = "";
$pass1 = "";
$db1 = "";
$host1= "";
$conn1 = mysql_connect($host1, $user1, $pass1);

$user2 = "";
$pass2 = "";
$db2 [...]