OCIEnvNlsCreate() failed. When i try to connect my oracle database in php

18,959

Solution 1

I solved it copying all the content of C:\instantclient_11_2 (please check what´s yours) inside system and system32 folders in Windows , then I delete the path of C:\instantclient_11_2 in the PATH enviroment variable.

I am using XAMPP and Windows 8 and it´s the first time I see this issue. I always configured properly oci 8 with xampp and windows in a few minutes. I hope this would help you.

Solution 2

You need to copy all content of the instant client to apache/bin

im using xampp and working for me.

copy all files of the instant client enter image description here to apache/bin

Solution 3

I was facing the same error on uwamp 3 in connecting to oracle 11gR2.

I deleted the oracle instantclient from path variable and copied all files from instantclient to uwamp\bin\apache\bin

and it worked.

My setup:

  • System: Windows 7
  • Instantclient: instantclient-basiclite-win32-11.1.0.7.0
  • Web Server: Uwamp3
Share:
18,959
dude
Author by

dude

open book

Updated on June 17, 2022

Comments

  • dude
    dude almost 2 years

    phpinfo

    _ENV["ORACLE_HOME"] C:\oracle\instantclient_11_2\
    _ENV["OS"]  Windows_NT
    _ENV["Path"]    C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\oracle\instantclient_11_2;\;
    

    oci8

    OCI8 Support    enabled
    Version     1.2.5
    Revision    $Revision: 1.269.2.16.2.43 $
    Active Persistent Connections   0
    Active Connections  0
    Temporary Lob support   enabled
    Collections support     enabled 
    

    php code

    <?php
         $conn = OCILogon('mppd1','mppd1', "121.256.476.86:1521/mydatabase");
    
    $query = 'select * from users';
    
    $stid = OCIParse($conn, $query);
    //OCIExecute($stid, OCI_DEFAULT);
    while ($succ = OCIFetchInto($stid, $row)) {
    foreach ($row as $item) {
    echo $item." ";
    }
    echo "<br>\n";
    }
    
    OCILogoff($conn);
    ?>
    

    i am getting this error

    Severity: Warning
    
    Message: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries
    
  • Pankaj Wanjari
    Pankaj Wanjari over 8 years
    I solved with above solution on windows 7 with wampserver.
  • manix
    manix almost 6 years
    This saved me 4 days of suffering!
  • ffuentes
    ffuentes over 4 years
    Also everyone, check that you have the right version of the library and that both client and odbc match version and architecture.