2013-10-11 79 views
0

我在从远程服务器上的Oracle 10g数据库检索数据时遇到问题。我在Linux Debian网络服务器上使用PHP,并且oci8已启用并正在运行。我只是得到一个空白页面。代码如下:使用PHP从Oracle数据库检索数据

<?php 
$conn = oci_connect('username','password','//server IP address:1521/servicename'); 

if (!$conn) { 
    $e = oci_error(); 
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); 
} 
// Prepare the statement 
$stid = oci_parse($conn, 'SELECT * FROM table'); 
if (!$stid) { 
    $e = oci_error($conn); 
    //trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); 
} 
// Perform the logic of the query 
$r = oci_execute($stid); 
if (!$r) { 
    $e = oci_error($stid); 
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); 
} 
// Fetch the results of the query 
print "<table border='1'>\n"; 
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) { 
    print "<tr>\n"; 
    foreach ($row as $item) { 
     print " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n"; 
    } 
    print "</tr>\n"; 
} 
print "</table>\n"; 
oci_free_statement($stid); 
oci_close($conn); 
?> 

我不知道如何清楚地定义我想连接的数据库,因为服务器上有多个Oracle数据库。

任何帮助将不胜感激。

+0

是否打开了错误报告?你会得到任何错误消息,可以帮助你调试吗? – Maximus2012

+0

我只是得到一个空白页面,所以会打开错误报告 – Marcus

回答

0

现在已解决问题。

一旦我添加了错误报告,我得到了ocienvnlscreate()失败的LD_LIBRARY_PATH问题。这是为LD_LIBRARY_PATH设置的路径或instantclient目录的权限,它是后者。非常感谢您的回复Maximus2012。