将php连接到数据库

时间:2014-09-30 06:52:40

标签: php mysql

大家好我是非常新的openshift和php.So我如何将我的php连接到我的openshift数据库?更具体地说,我的php连接脚本应该连接到我的MySQL数据库?

这些是我的装备

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:       *********

1 个答案:

答案 0 :(得分:0)

简单试试这个

<?php
$con = mysql_connect('servername','username','password');
$connect = mysql_select_db('databasename');
if($connect)
{
echo "database connected";
}
?>