简体   繁体   English

如何使用 IBM Bluemix 连接 php 文件以连接数据库?

[英]How do i connect the php file to connect database using IBM Bluemix?

I have some problem我有一些问题

code line代码行

$servername="us--------03.cleardb.net";

$user="be9-------0";

$pass="f9-------";

$db="ad_50f-------fa6a";    

$con = mysql_connect($servername, $user, $pass, $db);
mysql_select_db($db);

My Requirement我的要求

I implement this line code could not be working than how should be connect database in ibm bluemix!!我实现这一行代码无法正常工作,而应该如何在 ibm bluemix 中连接数据库!!

plz given me solution..请给我解决方案..

mysql_connect is deprecated.不推荐使用 mysql_connect。 Use this code as an example:使用此代码作为示例:

$mysqli = new mysqli($mysql_server_name, $mysql_username, $mysql_password, $mysql_database);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    die();
}

Your composer.json needs to have:你的 composer.json 需要有:

{
  "require": {
    "ext-mysqli": "*"
  }
}

https://github.com/IBM-Bluemix/php-mysql See: db.php and composer.json https://github.com/IBM-Bluemix/php-mysql参见:db.php 和 composer.json

To view the logs, use this command:要查看日志,请使用以下命令:

cf logs <yourappname> --recent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM