A little note about multiple simultaneous connections to different hosts...
I work on a site that pulls content primarily from one db but uses a db on a foreign server to verify licensing. One might expect the following to work:
// Open the connection to the primary db
$res1 = mysql_connect($host1, $user1, $pass1);
mysql_select_db($db1);
// Open connection to the license server
$res2 = mysql_connect($host2, $user2, $pass2);
mysql_select_db($db2, $res2);
// Pull license data and close when done
mysql_query($check_sql, $res2);
...
mysql_close($res2);
// Now pull content from the primary db
// Not specifying the resource should default to the last open db
mysql_query($query);
...
Turns out this last query, since it cant find an active connection, will try to connect with mysql_connect() with no paramaters. But if instead you do it as mysql_query($query, $res1), or alternatively, run the mysql_connect for this host again then it works fine. Thus, it doesnt seem to be possible to have code with an overarching "global" db connection interspersed with temporary connections to another host/db....