its easy i think
you should make two db handlers

PHP Code:
//your primary connection
$conn mysql_connect("host1","username","password");

if(
$conn){
   
//connect to your first db with first handle
   
mysql_select_db('database1'$conn); 

   
$conn2 mysql_connect("host1","username","password",true); 
    
//should put that true to make a new connection

   //connect to your second db with 2nd handle
   
mysql_select_db('database2'$conn2); 

you can make with the same handle as well

and dont use the MAKE connection thing inside a loop
unless it will make multiple connections
if you have no option, use mysql_pconenct
but if you put your code, i can tell you better