4 Replies Latest reply: Apr 16, 2013 4:41 PM by ebsappsgirl RSS

    Warning: oci_pconnect(): OCIEnvNlsCreate() failed.

    ebsappsgirl
      So I installed apache 2, then PHP, and Oci8. Then I installed my database. I installed all the other packages Oracle said that I needed. Apache is working great, the database is fine.

      I'm trying to connect to my database.


      Here is the php code I'm using to test the connection first in /var/www/html/oci8.php
      <?php
      $c = oci_pconnect("hr", "welcome", "lionheartdb");
      if (!$c) {
      $e = oci_error();
      trigger_error('Could not connect to database: '. $e['message'],E_USER_ERROR);
      }
      $s = oci_parse($c, "select city from locations order by city");
      if (!$s) {
      $e = oci_error($c);
      trigger_error('Could not parse statement: '. $e['message'], E_USER_ERROR);
      }
      $r = oci_execute($s);
      if (!$r) {
      $e = oci_error($s);
      trigger_error('Could not execute statement: '. $e['message'], E_USER_ERROR);
      }
      echo "<table border='1'>\n";
      $ncols = oci_num_fields($s);
      echo "<tr>\n";
      for ($i = 1; $i <= $ncols; ++$i) {
      $colname = oci_field_name($s, $i);
      echo " <th><b>".htmlentities($colname, ENT_QUOTES)."</b></th>\n";
      }
      echo "</tr>\n";
      while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
      echo "<tr>\n";
      foreach ($row as $item) {
      echo " <td>".($item!==null?htmlentities($item,
      ENT_QUOTES):" ")."</td>\n";
      }
      echo "</tr>\n";
      }
      echo "</table>\n";
      ?>


      This is the error I am receiving when I try to run http://localhost.oci8.php from the browser:


      Warning: oci_pconnect(): OCIEnvNlsCreate() failed. There is something
      wrong with your system - please check that ORACLE_HOME and
      LD_LIBRARY_PATH are set and point to the right directories in
      /var/www/html/oci8.php on line 3


      Warning: oci_pconnect(): Error while trying to retrieve text for error
      ORA-01804 in /var/www/html/oci8.php on line 3


      Fatal error: Could not connect to database: in /var/www/html/oci8.php on line 6
      ___________________________________________________________________


      I've been troubleshooting this error for 2 days now. I know it is saying my environments are not set correctly, but I'm at a lost. Here is my .profile.db settings


      ORACLE_HOSTNAME=oracle.localdomain; export ORACLE_HOSTNAME
      ORACLE_UNQNAME=lionheartdb; export ORACLE_UNQNAME
      ORACLE_BASE=/admdba/lionheartdb/oracle; export ORACLE_BASE
      ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME
      ORACLE_SID=lionheartdb; export ORACLE_SID
      PATH=/usr/sbin:$PATH; export PATH
      PATH=$ORACLE_HOME/bin:$PATH; export PATH


      LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH


      and I also set ORACLE_HOME and LD_LIBRARY_PATH in my /usr/local/apache2/bin/envvars
      export LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
      export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME




      when i go to http://localhost.phpinfo.php to see the values set there this is what I'm shown
      oci8
      OCI8 Support enabled
      Version 1.4.9
      Revision $Id: e2241cffb72c940cb2ca267b7a6a0ce436de7e5e $
      Active Persistent Connections 0
      Active Connections 0
      Oracle Run-time Client Library Version 11.2.0.1.0
      Oracle Version 11.2
      Compile-time ORACLE_HOME /admdba/lionheartdb/oracle/product/11.2.0/lionheartdb
      Libraries Used -Wl,-rpath,/admdba/lionheartdb/oracle/product/11.2.0/lionheartdb/lib
      -L/admdba/lionheartdb/oracle/product/11.2.0/lionheartdb/lib -lclntsh
      Temporary Lob support enabled
      Collections support enabled




      I have no clue where to go from here, do you see anything I missed? Can you point me in the right direction? Thanks