Connecting to a mysql database from a separate Application
First time using OpenShift, and I've read that I am able to connect to a
database on a different application under my account.
I have APPLICATION A that is a Ruby/MySQL project. I have APPLICATION B
that is a PHP project.
I'd like to connect to my APPLICATION A MySQL database from my APPLICATION
B PHP script. When doing an rhc apps command, I can see that my connection
URL reads:
Connection URL: mysql://$OPENSHIFT_MYSQLDB_HOST:$OPENSHIFT_MYSQLDB_PORT
When looking at my environment variables on my APPLICATION A server, I see
they are:
OPENSHIFT_MYSQLDB_PORT=3306
OPENSHIFT_MYSQL_HOST=127.7.171.129
But when I try to connect:
$db = new mysqli('http://127.7.171.129', 'adminuser', 'adminpw',
'productiondb',3306);
And I dump out this:
object(mysqli)#1 (17) {
["affected_rows"]=>
NULL
["client_info"]=>
NULL
["client_version"]=>
int(50169)
["connect_errno"]=>
int(2005)
["connect_error"]=>
string(57) "Unknown MySQL server host 'http://127.7.171.129' (1)"
["errno"]=>
NULL
["error"]=>
NULL
["field_count"]=>
NULL
["host_info"]=>
NULL
["info"]=>
NULL
["insert_id"]=>
NULL
["server_info"]=>
NULL
["server_version"]=>
NULL
["sqlstate"]=>
NULL
["protocol_version"]=>
NULL
["thread_id"]=>
NULL
["warning_count"]=>
NULL
}
No comments:
Post a Comment