2013-10-11 6 views
0

원격 서버의 Oracle 10g 데이터베이스에서 데이터를 검색하는 데 문제가 있습니다. Linux 데비안 웹 서버에서 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.

관련 문제