Jump to content

Is there a way to connect to one mysql db while connected to another one?


tibberous

Recommended Posts

I am using a 3rd party lookup service. Basically, they have you connect to their mysql database, select their db and do a query.

 

I tried:

 

$newconn = mysql_connect()
mysql_select_db('db', $newconn);
mysql_query("...", $newconn);
mysql_close($newconn);

 

But if I try to do mysql_queries without sending $newconn I still get errors. For right now, I'm just closing my first connection and reconnecting, but it seems like there should be a way to query a second database without messing up the connect to the first one.

I am using a 3rd party lookup service. Basically, they have you connect to their mysql database, select their db and do a query.

 

I tried:

 

$newconn = mysql_connect()
mysql_select_db('db', $newconn);
mysql_query("...", $newconn);
mysql_close($newconn);

 

But if I try to do mysql_queries without sending $newconn I still get errors. For right now, I'm just closing my first connection and reconnecting, but it seems like there should be a way to query a second database without messing up the connect to the first one.

 

There's a boolean you can set in mysql_connect that will force it to create a new, parallel connection to a db: mysql_connect  However, I think it only applies if you're trying to attempt multiple connections to the same db.  If the db's are actually different, then the db handle you create during mysql_connect should be enough.

 

Can you show more code in how you're creating and using these connections?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.