我看过这篇非常有用的帖子Questions,并尝试按照其概述的步骤进行操作。不过我是新手,所以我觉得我可能搞砸了。
我试图在网页上定制代码,该代码是为了记录某人的情况而创建的。
我正在制作日历,这就是我需要这个数据库的原因。主要目标:在Bluemix中创建类似日历的Web应用程序,并将数据库服务绑定到它,以便我可以存储事件。
这是我采取的步骤:
然而,当我完成所有这些,然后使用此命令推出我的项目" 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 log (我无法在这里完全适应,但如果您需要其他线路,或者我还有其他方式向您展示,请告知我们)
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
答案 0 :(得分:2)
您需要确保您的CF应用程序包含PHP的dashDB / DB2驱动程序。将此附加到cf push命令会修复它, -b https://github.com/ibmdb/db2heroku-buildpack-php
答案 1 :(得分:0)
您需要安装db2软件包驱动程序。
如果您安装了Cloud Foundry,请运行此命令:cf push -b https://github.com/ibmdb/db2heroku-buildpack-php
或者
将buildpack选项添加到manifest.yml文件[manifest.yml]中 Buildpack:https://github.com/ibmdb/db2heroku-buildpack-php