-3

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!!

plz given me solution..

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
B.Nadesh kumar
  • 216
  • 1
  • 10

1 Answers1

1

mysql_connect is deprecated. 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:

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

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

To view the logs, use this command:

cf logs <yourappname> --recent
Ram Vennam
  • 3,536
  • 1
  • 12
  • 19