1 2 Previous Next 18 Replies Latest reply on Jun 11, 2010 9:24 PM by cj

    OCIEnvNlsCreate() failed

      i have installed instantclient_10_2
      i have installed Apache/1.3.22 (Win32) PHP/5.2.1
      i have the system variables NLS_LANG : AMERICAN_AMERICA.WE8MSWIN1252 LD_LIBRARY_PATH : c:\instantclient_10_2
      ORACLE_HOME : c:\instantclient_10_2\
      Path : c:\instantclient_10_2\;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Program Files\apache group\apache\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Wave Systems Corp\Dell Preboot Manager\Access Client\v5\;c:\php

      phpinfo say to me:
      oci8 OCI8 Support enabled Version 1.2.3 Revision $Revision: $ Active Persistent Connections 0 Active Connections 0 Temporary Lob support enabled Collections support enabled Directive Local Value Master Value oci8.default_prefetch 10 10 oci8.max_persistent -1 -1 oci8.old_oci_close_semantics 0 0 oci8.persistent_timeout -1 -1 oci8.ping_interval 60 60 oci8.privileged_connect Off Off oci8.statement_cache_size 20 20

      and when i try to do $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX)(PORT = 1521)))(CONNECT_DATA=(SID=essai)))"; $conn = oci_connect("user","password",$db);
      i have the error message: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in C:\Program Files\Apache Group\Apache\htdocs\manual\essai_ora_v2.php on line 28

      I have read all the notes about this problem and i have tried all but i have allways the same problem Can you help me please

      Thanks Jean-Philippe Fagniez
        • 1. Re: OCIEnvNlsCreate() failed
          After another day of unsuccessful experiments I still couldn't make my remote connection work.

          But I found out, after I switched from the MDB2 functions to PHP's standard OCI functions, that I've got the same problem with the "PATH Error" as you describe it here but I only didn't see it before because MDB2's error message was not that clear.

          One very interesting thing is that I can connect to the remote server with my client's "10 XE Client (installer version)" from the SQL command line without any problems.

          Did you have any success today ? :-)

          *** Michl
          • 2. Re: OCIEnvNlsCreate() failed
            I can connect with sql*plus but not in php
            I do not know how to make to succeed
            • 3. Re: OCIEnvNlsCreate() failed
              Hi Jean-Philippe,

              I finally solved the problem on my machine !

              I did some side-by-side comparisons between the phpInfo() output of my well working server's XAMPP environment(v. 1.5.1)
              and the output of the remote client's environment (v. 1.6.0a).

              The result is that the "php_oci8.dll" bundled with the earlier XAMPP version on my server has a higher version number ("1.28***")
              (although it's definetly older as the file timestamp shows) than the (newer) one included with later XAMPP distribution ("1.26**") on my client.

              My first attempt to fix it was to replace the client's 1.26 with the server's 1.28 but this didn't work because it disabled
              PHP's OCI8 support after a Apache restart.

              The next try was the successful one but I had to switch back to PHP 5.1.1 (that's not really a big thing for me).

              1. Uninstall the client's current XAMPP environment (1.6.0a) completly using the uninstaller.

              2. Install XAMPP (1.5.1).

              3. Check that the "Instand Client Basic" is installed in a folder and the path to that folder is included at the beginning of
              your global "Path" environment variable.
              (e.g.: D:\oracleclient;%SystemRoot%\system32;...)

              I also removed all other environment variables I created during my previous tests and experiments like "ORACLE_HOME", ...
              because they're not neccesary.

              4. Uncomment the "php_oci8.dll" inside the "php.ini".

              5. Restart the Apache.

              6. Check phpInfo() for OCI8 support enabled.

              7. Check that you use the correct DSN or Database syntax in your PHP script.

              Standard PHP OCI functions:
              oci_connect("user", "password", "//")

              MDB2 DSN:

              8. Your remote database connection should work now.

              *** Michl
              • 4. Re: OCIEnvNlsCreate() failed
                allways the problem
                I have installed xamp like you have said

                and now I have this message:
                Warning: oci_connect() [function.oci-connect]: OCIEnvInit() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in C:\Program Files\xampp\htdocs\xampp\essai_ora_v1.php on line 13

                when i use regedit only one variable ORACLE_HOME : c:\instant_client_10_2 !!!

                this is my file essai_ora_v1.php:

                print(date("1 F d, Y"));
                $db = oci_connect("user","password",$db);

                I am disappointed, I think that there are no solutions!!!!

                • 5. Re: OCIEnvNlsCreate() failed

                  You shouldn't need ORACLE_HOME with instant client.

                  Instead of:
                  print(date("1 F d, Y"));
                  $db = oci_connect("user","password",$db);

                  print(date("1 F d, Y"));
                  $c=OCILogon("user", "password", "XXX.XXX.XXX.XXX:1521/YYY");

                  Hope this helps
                  • 6. Re: OCIEnvNlsCreate() failed
                    As the previous poster pointed out you don't need ORACLE_HOME set when you are using Instant Client. Also LD_LIBRARY_PATH is a UNIX variable.

                    Unset both of these. Also try unsetting NLS_LANG and let it default for the moment.

                    Are you sure there is no other Oracle software on the machine or values in the registry?

                    -- cj
                    • 7. Re: OCIEnvNlsCreate() failed
                      I've met absolutely the same problem.

                      And it was solved here: http://www.thescripts.com/forum/thread637481.html

                      The thing is - you simply must change permissions for some oracle files by script: $ORACLE_HOME/install/changePerm.sh

                      After I made so - no problems.

                      • 8. Re: OCIEnvNlsCreate() failed
                        Hi everybody,
                        Sorry for asking how i can make this changing in permission under windows??
                        where i could run this script??
                        thanks for your help,
                        • 9. Re: OCIEnvNlsCreate() failed
                          Hey everybody. I also wunder how to change the permissions under windows. I hope yu kan help me

                          Message was edited by:
                          • 10. Re: OCIEnvNlsCreate() failed
                            I've not heard that Windows has the same permission issue?
                            If you have a similar error, start a new thread.

                            -- cj
                            • 11. Re: OCIEnvNlsCreate() failed
                              I don't think this problem has anything to do with file permissions, but is actually exactly as the error message suggests : that environment variables are not set as far as PHP/Apache is concerned. I've had this same problem but have finally found a solution.

                              First, check if the env-variables ORACLE_HOME and NLS_LANG are actually being picked up by PHP. I had set and exported them before starting Apache (using sudo) but using phpinfo() the "PHP Variables" section (near the end) didn't show either of these variables as being set, just as the error message suggested.

                              The solution was to include both ORACLE_HOME and NLS_LANG variables in the "envvars" file which is located in the same directory as apachectl (the script you use to start the apache daemon).
                              Add the two entries exactly as you would as if they were in a .profile
                              export ORACLE_HOME=/Volumes/u01/app/oracle/product/10.1.0/db_4
                              export NLS_LANG=.AL32UTF8

                              Save the file, and restart apache.
                              Using phpinfo() you should now see both variables listed in the "PHP Variables" section.
                              PHP should now be able to connect to Oracle
                              • 12. Re: OCIEnvNlsCreate() failed
                                I was beating my head against the wall trying to figure this out. Adding the exports to envvars detailed by user488828 was the ticket.

                                Thanks. You're the man (or woman)!

                                Ypsilanti, MI
                                • 13. Re: OCIEnvNlsCreate() failed
                                  Where they need to be set is OS and version specific. There's a section on "Setting Oracle Environment Variables for Apache" in http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf which has some general guidelines.
                                  • 14. Re: OCIEnvNlsCreate() failed
                                    That or, edit /etc/group and simply add www-data (apache user) to oinstall group.
                                    1 2 Previous Next