Forum Stats

  • 3,825,945 Users
  • 2,260,582 Discussions
  • 7,896,739 Comments

Discussions

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

3276943
3276943 Member Posts: 99 Green Ribbon
edited Feb 8, 2017 3:41PM in PHP

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

Batgerel Byarvaa

Answers

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,785 Bronze Crown
    edited Feb 7, 2017 7:12AM

    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.

    Batgerel Byarvaa
  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,648 Employee
    edited Feb 8, 2017 3:41PM

    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
This discussion has been closed.