MySQL connection attempt works fine in 5.2.9 but not in 5.3.0 - Help?
Posted
by Rich
on Stack Overflow
See other posts from Stack Overflow
or by Rich
Published on 2010-05-12T07:59:08Z
Indexed on
2010/05/12
8:04 UTC
Read the original article
Hit count: 173
Hi,
I'm having trouble making a secondary MySQL connection (to a separate, external DB) in my code. It works fine in PHP 5.2.9 but fails to connect in PHP 5.3.0. I'm aware of (at least some) of the changes needed to make successful MySQL connections in the newer version of PHP, and have succeeded before, so I'm not sure why it isn't working this time.
I already have a db connection open to a local database. This function below is then used to make an additional connection to a separate, remote directory. The included config file simply contains the external database details (host, user, pass and name). I have checked and it is being included correctly.
function connectDP() {
global $dpConnection;
include("secondary_db_config.php);
$dpConnection = mysql_connect($dp_dbHost, $dp_dbUser, $dp_dbPass, true) or DIE("ERROR: Unable to connect to Deployment Platform");
mysql_select_db($dp_dbName, $dpConnection) or DIE("ERROR 006: Unable to select Deployment Platform Database");
}
I then attempt to make this new connection simply by calling this function externally:
connectDP();
But when loading the page (in 5.3.0), I get the message:
ERROR: Unable to connect to Deployment Platform
I'm using the optional new_link
flag boolean as the fourth argument in the mysql_connect()
function and it's still not working.
I've been wracking my brain this morning trying to figure out why this connection doesn't work (while I've done something very similar elsewhere to a separate second database that does work). Any help would be appreciated.
Thanks!
Rich
© Stack Overflow or respective owner