2011-07-05 107 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