简体   繁体   English

使用PHP连接到Bluemix中的dashdb

[英]Using PHP to connect to dashdb in bluemix

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.";
}

?>

The hostname that you are using is not the database server, but for the webconsole (see port 8443). 您使用的主机名不是数据库服务器,而是Web控制台的主机名(请参阅端口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. 要解决该错误,请从dashDB仪表板中的Connection菜单或Bluemix服务概述中的Credentials选项卡中获取正确的连接信息。

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

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