2011-07-05 108 views
1

我的錯誤代碼是:PHP + ORACLE連接問題

Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /data01/app/htdocs/doosanclub/include/classes.pinc on line 47 

和線47是:

46:  function connect($DBuser,$DBpassword,$DBsid) { 
47:  $this->conn = OCILogon($DBuser,$DBpassword,$DBsid); 
48:  $this->mode = OCI_DEFAULT; 
49: } 

我ORACLE_HOME設置在root.sh:ORACLE_HOME=/oracle

/oracle和是一個包含/bin的正確目錄。

和..我的$ DBsid值也在/oracle/network/admin/tnsnames.ora中定義。

我搜索了一些docs並嘗試它。我做了一個測試php文件。 的代碼是:

oci_internal_debug(1); // turn on tracing 
$conn = oci_connect("id", "pw", "SID"); 

並顯示:

OCI8 DEBUG: OCINlsEnvironmentVariableGet at (/temp/php_source/php-5.2.13/ext/oci8/oci8.c:1067) OCI8 DEBUG: OCIEnvNlsCreate at (/temp/php_source/php-5.2.13/ext/oci8/oci8.c:1223) 
Warning: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /data01/app/htdocs/doosanclub/db_connect_test.php on line 23 
OCI8 DEBUG: OCIHandleFree at (/temp/php_source/php-5.2.13/ext/oci8/oci8.c:1547) 

ORACLE_HOME再次..也許是錯的..?我不知道..

這是第一次設置這些東西。 請幫我解決這個問題。謝謝!

+0

可能是一些文件permissioin問題?在用戶apache下運行php腳本?它有權限讀取/ oracle目錄嗎? – heximal

+1

你怎麼在環境看,當你運行「的phpinfo()」 –

+0

詹姆斯 - 安德森//什麼樣的信息,你需要知道解決這個問題?我很抱歉,但由於安全問題,我無法給你全部信息。 – Deckard

回答

0

我解決了這個問題,只是通過將putenv()添加到連接PHP文件的數據庫中。

putenv("ORACLE_HOME=/oracle"); 

但很奇怪的是phpinfo();顯示ORACLE_HOME=/oracle之前,我設置ORACLE_HOME