0
votes

I'm trying to connect to my mysql DB on OpenShift Online that has been set up as a scalable gear, and the connection URL that OpenShift provides

mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/

does not connect. When using this as the localhost parameter within mysql_connect(), I am unable to connect to my DB. When I set the gear up as non-scalable, which provides the actual host ip and port when adding mysql to the gear, this works perfectly. Below is an example of how I would input this.

$DBconnect = mysql_connect("mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/", "UserName","PassWord","DB");

Does anyone have any experience connecting to a scalable gear on OpenShift, and what I might be doing wrong?

Thanks,

1

1 Answers

0
votes

Have you tried adding some simple error processing code to help you work out what might be going wrong, like

$DBconnect = mysql_connect("mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/", "UserName","PassWord","DB");

if (!$DBconnect) {
    die('Could not connect: ' . mysql_error());
}

This may well give you an error message that allows you to work out what the problem is!

HINT:

It looks to me like this is expecting that you have created variables called

$OPENSHIFT_MYSQL_DB_HOST = 'SomeHostName';
$OPENSHIFT_MYSQL_DB_PORT = 'SomePortNumber';

before running the mysql_connect, have you done that? Or included their file with these already defined?