douluan1533 2011-07-05 07:14
浏览 142
已采纳

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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序