-1

Hi guys im very new to openshift and php.So how do i connect my php to my openshift database?To be more specific,what should be my php connection script in order to connect to my MySQL database?

These are my gears

Domain:     testing123hello
Created:    May 21  1:41 PM
Gears:      2 (defaults to small)
Git URL:    ssh://537c3c7a4382ec54ff000007@php-testing123hello.rhcloud.com/~/g
it/php.git/
SSH:        537c3c7a4382ec54ff000007@php-testing123hello.rhcloud.com
Deployment: auto (on git push)

haproxy-1.4 (Web Load Balancer)

Gears: Located with php-5.4

php-5.4 (PHP 5.4)

Scaling: x1 (minimum: 1, maximum: available) on small gears

mysql-5.5 (MySQL 5.5)


  Gears:          1 small
  Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
Database Name:  php
Password:       *********
Username:       *********
  • possible duplicate of [how to connect to the database in openshift application](http://stackoverflow.com/questions/15921169/how-to-connect-to-the-database-in-openshift-application) (one of the *first* results when Googling "php openshift database") – h2ooooooo Sep 30 '14 at 07:38
  • Is the script to be put under the mysql_connect.php file? – Muhd Rizwan Sep 30 '14 at 07:41

1 Answers1

0

Its Simple Try This

<?php
$con = mysql_connect('servername','username','password');
$connect = mysql_select_db('databasename');
if($connect)
{
echo "database connected";
}
?>
sameer kumar
  • 149
  • 2
  • 3
  • 13