0

This is the code that I have so far. I've checked the credentials a million times, so I know they're correct. I'm not sure what's going wrong. Could someone please help me out? Thanks in advance!

<?php
$database = "BLUDB";
$user = "xxx";
$password = "yyyy";
$hostname = "dashdb-entry-yp-dal09-07.services.dal.bluemix.net:8443";
$port = 50000;

$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" . "HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";



$conn = db2_connect($conn_string, '', '');

if ($conn) {
    echo "Connection succeeded.";
    db2_close($conn);
}
else {
    echo "Connection failed.";
}

?>
Marc B
  • 356,200
  • 43
  • 426
  • 500
  • 1
    Thanks for your login credentials... might want to go change those **IMMEDAITELY**. And don't output a fixed/unchanging error message - they're useless. Have the DB tell you what failed: http://php.net/manual/en/function.db2-conn-error.php – Marc B Jun 17 '16 at 18:15

1 Answers1

0

The hostname that you are using is not the database server, but for the webconsole (see port 8443). You get the error because your string for the hostname already includes the port number AND the entire hostname is incorrect.

To fix the error get the correct connection information from either the Connection menu in the dashDB dashboard or the Credentials tab in your Bluemix service overview.

data_henrik
  • 16,724
  • 2
  • 28
  • 49