OCIEnvNlsCreate() failed

user564695
    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: 1.269.2.16.2.30 $ 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
        567433
        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
          user564695
          I can connect with sql*plus but not in php
          I do not know how to make to succeed
          thanks
          Jean-Philippe
          • 3. Re: OCIEnvNlsCreate() failed
            567433
            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", "//130.50.15.224/xe")

            MDB2 DSN:
            oci8://user:password@/130.50.15.224/xe

            8. Your remote database connection should work now.



            *** Michl
            • 4. Re: OCIEnvNlsCreate() failed
              user564695
              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:

              <?php
              print(date("1 F d, Y"));
              $db = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX) (PORT = 1521)))(CONNECT_DATA =(SID = YYY)))";
              $db = oci_connect("user","password",$db);
              ?>

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

              Jean-Philippe
              • 5. Re: OCIEnvNlsCreate() failed
                562647
                Goodmorning,

                You shouldn't need ORACLE_HOME with instant client.

                Instead of:
                <?php
                print(date("1 F d, Y"));
                $db = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX) (PORT = 1521)))(CONNECT_DATA =(SID = YYY)))";
                $db = oci_connect("user","password",$db);
                ?>


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


                Hope this helps
                • 6. Re: OCIEnvNlsCreate() failed
                  cj
                  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
                    490742
                    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.

                    Sergey
                    • 8. Re: OCIEnvNlsCreate() failed
                      617157
                      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
                        552054
                        Hey everybody. I also wunder how to change the permissions under windows. I hope yu kan help me

                        Message was edited by:
                        user549051
                        • 10. Re: OCIEnvNlsCreate() failed
                          cj
                          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
                            491831
                            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
                            eg:
                            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
                              CaptainPackers
                              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)!

                              Don
                              Ypsilanti, MI
                              • 13. Re: OCIEnvNlsCreate() failed
                                cj
                                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
                                  703855
                                  That or, edit /etc/group and simply add www-data (apache user) to oinstall group.
                                  1 2 上一个 下一个