tibberous Posted March 5, 2010 Share Posted March 5, 2010 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. Link to comment https://forums.phpfreaks.com/topic/194277-is-there-a-way-to-connect-to-one-mysql-db-while-connected-to-another-one/ Share on other sites More sharing options...
KevinM1 Posted March 5, 2010 Share Posted March 5, 2010 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? Link to comment https://forums.phpfreaks.com/topic/194277-is-there-a-way-to-connect-to-one-mysql-db-while-connected-to-another-one/#findComment-1022060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.