If you want to connect with different server with different credentials, then you need to connect with all the different servers and for each handle, you need to select the database and the queries.
$handle_db1 = mysql_connect("localhost","myuser","apasswd");
$handle_db2 = mysql_connect("127.0.0.1","myuser","apasswd");
$handle_db3 = mysql_connect("localhost:3306","myuser","apasswd");
$handle_db4 = mysql_connect("localhost","otheruser","apasswd");
We select the databases with each handle.
// give each handle it's own database to work with, permanently.
mysql_select_db("db1",$handle_db1);
mysql_select_db("db2",$handle_db2);
mysql_select_db("db3",$handle_db3);
mysql_select_db("db4",$handle_db4);
And for querying the databases, we also set the handlers here.
//do a query from db1:
$query = "select * from test"; $which = $handle_db1;
mysql_query($query,$which);
The below is for our second database.
//do a query from db2 :
$query = "select * from test"; $which = $handle_db2;
mysql_query($query,$which);
See the book
OpenCart 1.4 Template Design Cookbook.
See the book
Joomla Mobile Development Beginners Guide