1

我已经看到这个非常有用的帖子问题,并尝试按照它概述的步骤进行操作。但是我对此很陌生,所以我想我可能在某个地方搞砸了。

我试图定制网页上的代码,该代码是为了让某人登录到我的情况而创建的。

我正在制作一个日历,这就是我需要这个数据库的原因。主要目标:在 Bluemix 中制作类似日历的 Web 应用程序并将数据库服务绑定到它,以便我可以存储事件。

这些是我采取的步骤:

  1. 使用 PHP、HTML 和 CSS 创建了一个网站
  2. 绑定服务 (dashDB) 并通过上传包含两列的 .csv 文件放入表中,一列标记为用户名,另一列标记为密码。有两条记录,(Jessica - Fish, Tom - Bear) 它被称为 USERNAMEFILE
  3. 包括一个 php 文件,该文件将连接到名为 ConexionDB.php 的数据库
  4. '需要'我尝试访问数据库的名为 index.php 的 php 文件中的 ConexionDB.php 文件。在尝试访问数据库时,我只是想看看是否可以。它目前除了打印数字 1 之外没有其他用途。

但是,当我完成所有这些操作,然后使用此命令“cf push 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"].
";";

?>

索引.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
4

2 回答 2

2

您需要确保您的 CF 应用程序包含 PHP 的 dashDB/DB2 驱动程序。将此附加到您的 cf push 命令将修复它,-b https://github.com/ibmdb/db2heroku-buildpack-php

于 2017-04-13T13:54:13.027 回答
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

于 2017-07-25T07:53:43.800 回答