you're trying to connect to two different tables within two different databases?
i'm not sure i see the problem...
did you just connect to the db's when you needed them? or just connect one after the other. i'm pretty sure connects don't persist through one another so if you connect to one you'll have to reconnect to the previously connected db when you need something from it. i could be wrong about that.
either way, there's no reason you can't just query the first db, set the variables to what you need and then run the next query, connection sequence using the variables from the first query.
so, roughly speaking,
mysql_connect (blha, blha, blah);
$query = "SELECT FROM db";
$var1 = $results["whatever you're getting"];
etc.
msql_connect(other, other, other);
$query2 = "SELECT FROM db WHERE x ='$var1'";
etc.
etc.
gl...