PDA

View Full Version : Multiple Database Connections


westonm
04-18-2011, 09:20 PM
I have a site with two databases. In each page or php file I have a require_once call to a connection file. It works fine with one, but when I add the second require_once for the second database, it errors out with an http 500 error. Am I permitted to have two open connections, and if so do I need to create both connections in one file or two seperate files? I have other require_once statements so I am thinking that is ok, but don't see any other code that could cause the problem.

westonm
04-19-2011, 12:46 AM
I have been researching and am even more confused now. the connection file called by require_once, uses mysql_pconnect function to create the connection. But mysql_pconnect does not use the database as a parameter. The two databases use the same host, username, and password, There is a parameter on mysql_connect for new_link where you can specify a new link, but there is no reference to the database, so do I even need a second connection? And mysql_pconnect doesn't appear to have the same new_link parameter.

edbr
04-19-2011, 01:56 AM
no, pconnect is for persistent connection to a server.