Skip to main content

Posts

Showing posts from April, 2013

MySQL Database Connection at OpenShift Redhat Cloud using PDO Class

I was very unhappy when my code was correct but could not connect to my mysql database in openshift. But after trying some tricks it got to work. So I will share some tips that you can also put to your PHP MySQL application in openshift. First thing to be noted is that when you create a PHP Application in OpenShift you will get some environmental variable. Which you can view them by using echo $ENV_NAME in the shell. Some of MYSQL DB Environmental variables in openshift clouds are follows. OPENSHIFT_MYSQL_DB_HOST OPENSHIFT_MYSQL_DB_PORT OPENSHIFT_MYSQL_DB_USERNAME OPENSHIFT_MYSQL_DB_PASSWORD OPENSHIFT_MYSQL_DB_SOCKET OPENSHIFT_MYSQL_DB_URL            You can Find more about it here OpenShift Variables Considering we have database name 'gitspot' and have a table name having demo where there is a field 'name' and has a record 'RedHat Openshift' Now create a php file conf.php which contains all the Database Host Port etc and the way