我已经看到这个非常有用的帖子Questions,并试图按照它概述的步骤。不过,我对此很陌生,所以我认为我可能已经搞乱了某个地方。Bluemix-将dashDB连接到PHP应用程序
我试图裁剪网页上的代码,该代码是为了记录某人进入我的情况而创建的。
我正在制作一个日历,这就是为什么我需要这个数据库。主要目标:在Bluemix中制作类似日历的Web应用程序,并将数据库服务绑定到Bluemix以便我可以存储事件。
这是我所采取的步骤:
- 创建了PHP,HTML网站,和CSS
- 绑定服务(dashDB),并通过上传了两个.csv文件放在一个表列,一个标记的用户名和其他密码。有两个记录,(杰西卡 - 鱼,汤姆 - 熊)这就是所谓的USERNAMEFILE
- 包括一个PHP文件,该文件会连接到名为ConexionDB.php
- “需要”的ConexionDB.php在php文件文件数据库叫做index.php,我尝试访问数据库。当试图访问数据库时,我只是想看看我能否。目前,它不符合任何其他比打印出数字1
不过我做这一切的时候,然后把我的项目了与此命令“CF推HybridCloudEventsTest -b GitHub,然后去我的网站,我得到目的该页面不工作错误代码500.我也可以把我的CMD行发生了什么,如果有帮助。我也提出了我的代码以及每个文件的标题。我没有包括我的所有index.php文件因为它的工作我的数据库代码把之前的,所以我相信这是问题所在。如果你需要我的索引和CSS代码我可以发布它。任何帮助表示赞赏
ConexionDB.php
<?php
if(getenv("VCAP_SERVICES")) {
$json = getenv("VCAP_SERVICES");
}
// No DB credentials
else {
throw new Exception("No Database Information Available.", 1);
}
// Decode JSON and gather DB Info
$services_json = json_decode($json,true);
$bludb_config = $services_json["dashDB"][0]["credentials"];
// Create DB connect string
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=".
$bludb_config["db"].
";HOSTNAME=".
$bludb_config["host"].
";PORT=".
$bludb_config["port"].
";PROTOCOL=TCPIP;UID=".
$bludb_config["username"].
";PWD=".
$bludb_config["password"].
";";
?>
的index.php
<html>
<head>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<?php
//Include DB conexion
require('includes/ConexionDB.php');
$tbl_name="SCHEMA.USERNAMEFILE"; // Table name
// username and password sent from form
$myusername="Jessica";
$mypassword="Fish";
// Connect to BLUDB
$conn = db2_connect($conn_string, '', '');
if ($conn) {
// Prepare, execute SQL and iterate through resultset
$sql="SELECT count(*) FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);
echo $result;
?>
</body>
</html>
CF登陆(我可能不适合所有在这里,但让我知道如果你需要其他行或是否有适合我一些其他的方式向您展示)
In file included from /tmp/staged/app/clidriver/include/sqlcli1.h:45:0,
from /tmp/pear/temp/ibm_db2/php_ibm_db2.h:37,
from /tmp/pear/temp/ibm_db2/ibm_db2.c:34:
/tmp/staged/app/clidriver/include/sqlcli.h:870:0: warning: "ODBCVER" redefined [
enabled by default]
^
In file included from /app/php/include/php/TSRM/tsrm_config.h:1:0,
from /app/php/include/php/TSRM/tsrm_config_common.h:13,
from /app/php/include/php/TSRM/tsrm_virtual_cwd.h:27,
from /app/php/include/php/main/php.h:401,
from /tmp/pear/temp/ibm_db2/ibm_db2.c:30:
/app/php/include/php/main/../main/php_config.h:2095:0: note: this is the location of the previous definition
#define ODBCVER 0x0300
/tmp/pear/temp/ibm_db2/ibm_db2.c:1299:32: warning: cast to pointer from integer
of different size [-Wint-to-pointer-cast]
^
/tmp/pear/temp/ibm_db2/ibm_db2.c:1308:32: warning: cast to pointer from integer
of different size [-Wint-to-pointer-cast]
SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)vParam, /* was (SQLPOINTER)&vParam */
SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)vParam,
^
/tmp/pear/temp/ibm_db2/ibm_db2.c:1328:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)vParam, /* was (SQLPOINTER)&vParam */
^
/tmp/pear/temp/ibm_db2/ibm_db2.c:1357:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
SQL_ATTR_ROWCOUNT_PREFETCH, (SQLPOINTER)vParam,
^
/tmp/pear/temp/ibm_db2/ibm_db2.c:1495:89: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
rc = SQLSetConnectAttr((SQLHDBC)((conn_handle*)handle)->hdbc, SQL_ATTR_AUT
OCOMMIT, (SQLPOINTER)pvParam, SQL_IS_INTEGER);
^
----------------------------------------------------------------------
/tmp/pear/temp/pear-build-vcaph4uzHz/ibm_db2-1.9.9/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Libraries have been installed in:
Build complete.
Don't forget to run 'make test'.
requested state: started
instances: 1/1
usage: 128M x 1 instances
urls: hybridcloudeventstest.mybluemix.net
last uploaded: Tue Jun 28 18:20:09 UTC 2016
stack: unknown
buildpack: https://github.com/ibmdb/db2heroku-buildpack-php
state since cpu memory disk deta
ils
#0 running 2016-06-28 02:21:50 PM 0.0% 67M of 128M 178.1M of 1G
请你能张贴的 CF日志HybridCloudEventsTest --recent –