douluan1533
2011-07-05 07:14 阅读 115

PHP + ORACLE连接问题

My error code is :

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

and the line 47 is :

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

My ORACLE_HOME is set in root.sh : ORACLE_HOME=/oracle

and /oracle is a correct directory that contains /bin.

and.. my $DBsid value is also defined in /oracle/network/admin/tnsnames.ora.

I googled some docs and try it. I made a test php file. THe code is :

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

and it displays :

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 again.. maybe it is wrong..? I don't know..

It's the first time to setup these things. Please help me out this problem. Thanks!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongmeng1875 dongmeng1875 2011-07-08 07:37

    I solved this problem just by adding putenv() into a DB connecting PHP file.

    putenv("ORACLE_HOME=/oracle");
    

    But it's very weird that phpinfo(); displays ORACLE_HOME=/oracle before I set ORACLE_HOME.

    点赞 评论 复制链接分享

相关推荐