2 Ответы Последний ответ: 08.02.2017 20:41, автор: cj

    oracle 12c not connect with php see error Call to undefined function oci_connect()

    3276943

      Dear

      I have 12c that run rightly

      now i try to connect with PhP

       

      i install

      Instant Client Downloads for Microsoft Windows (32-bit)

      and

      Instant Client Downloads for Microsoft Windows (64-bit)

      test both with download and install and set environment variable path

       

      and my php.ini have

      ;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client

       

      this line already 

       

      see my code

       

       

      <?php

       

      $conn = oci_connect('mfatest', 'testphp', 'localhost/pdborcl'); /==( also i try with 'HOST_IP:PORT/orcl')

      $query = 'select EMPNAME from  MDAEMPLOYEES';

      $stid = oci_parse($conn, $query);

      oci_execute($stid, OCI_DEFAULT);

      while ($row = oci_fetch_array($stid, OCI_ASSOC)) {

      foreach ($row as $item) {

      echo $item." | ";

      }

      echo "

      \n";

      }

      oci_free_statement($stid);

      oci_close($conn);

      ?>

       

      ================

       

      <?php

       

      $conn = oci_connect('mfatest', 'testphp', 'localhost/pdborcl'); /==( also i try with 'HOST_IP:PORT/orcl')

      $query = 'select EMPNAME from  MDAEMPLOYEES';

      $stid = oci_parse($conn, $query);

      oci_execute($stid, OCI_DEFAULT);

      while ($row = oci_fetch_array($stid, OCI_ASSOC)) {

      foreach ($row as $item) {

      echo $item." | ";

      }

      echo "

      \n";

      }

      oci_free_statement($stid);

      oci_close($conn);

      ?>

      but both code give me this error

       

      see error

      Fatal error: Uncaught Error: Call to undefined function oci_connect() in C:\xampp\htdocs\mfamda\test12c.php:2 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mfamda\test12c.php on line 2

       

       

      please give me idea what is the problem

       

       

      regard

        • 1. Re: oracle 12c not connect with php see error Call to undefined function oci_connect()
          Gaz in Oz

          An idea on windows is that the library path isn't set in the %PATH% variable, or perhaps the 32bit and 64bit instant clients are conflicting, with respect to your php install

          Here's what the PHP: Installation - Manual has to say on the matter:

          Installing OCI8 on Windows

          When using Oracle 10gR2 client libraries on Windows, uncomment the php.ini line extension=php_oci8.dll. When using Oracle 11gR2 or later client libraries, uncomment extension=php_oci8_11g.dll or extension=php_oci8.dll. With Oracle 12c libraries use extension=php_oci8_12c.dll or extension=php_oci8_11g.dll or extension=php_oci8.dll. Only one of these DLLs may be enabled at a time. DLLs with higher versions may contain more functionality. Not all DLLs may be available for all versions of PHP. Make sure extension_dir is set to the directory containing the PHP extension DLLs.

           

          If using Instant Client, set the system PATH environment variable to the Oracle library directory.

           

          Cheers,

           

          Gaz.

          • 2. Re: oracle 12c not connect with php see error Call to undefined function oci_connect()
            cj

            I agree with Gaz in Oz.  Only use one of the Instant Clients (with PHP 5 you'll almost certainly need the 32bit client).  Check the Instant Client directory is in PATH.  And uncomment (remove the semicolon) from the php.ini line

            ;extension=php_oci8_12c.dll