2014-09-30 123 views
-1

嗨,我很熟悉openshift和php.So如何將我的php連接到openshift數據庫?更具體地說,我的php連接腳本應該連接到我的MySQL數據庫?將php連接到數據庫

這是我的齒輪

Domain:  testing123hello 
Created: May 21 1:41 PM 
Gears:  2 (defaults to small) 
Git URL: ssh://[email protected]/~/g 
it/php.git/ 
SSH:  [email protected] 
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:  ********* 
+0

的[如何連接到數據庫openshift應用]可能重複(http://stackoverflow.com/questions/15921169/how-to-connect-to-the-database -in-openshift-application)(當谷歌搜索「php openshift數據庫」時的* first *結果之一) – h2ooooooo 2014-09-30 07:38:19

+0

腳本是放在mysql_connect.php文件下嗎? – 2014-09-30 07:41:31

回答

0

其簡單的嘗試這個

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

感謝您的答覆..服務器名是MySql權的主機名?這個腳本將在mysql_connect.php文件下? – 2014-09-30 07:37:27

+0

是的,你需要把連接文件。 – 2014-09-30 08:48:37

+0

我已經嘗試過,但我試圖在瀏覽器中啓動即時獲得空白頁面。任何原因爲什麼? – 2014-09-30 14:51:35