Call undefined function oci_connect ()

I got this error.

Fatal error: Call to undefined function oci_connect() $conn = oci_connect('localhost', 'username', 'password') or die(could not connect:'.oci_error) 

i.e. code.

This is the error I received.

 Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\org\org\php\myphp.php on line 51 

I checked the PHP DLL files in the ext folder.

Someone help in this matter in advance.

+6
source share
14 answers

I just spend THREE ALL DAYS struggling with this problem.

I used my ORACLE connection in Windows 7, and no problem. Last week, I just got a new computer with Windows 8. Install XAMPP 1.8.2. Every PHP / MySQL application on this server works fine. The problem occurred when I try to connect my php applications to Oracle DB.

Call undefined function oci_pconnect ()

And when I start / stop Apache with the changes, the weird “Warning” in “PHP Startup”, which is sent to the LOG with “PHP Warning: PHP Startup: in Unknown on line 0"

I did everything (uncommented php_oci8.dll and php_oci8_11g.dll, copied oci.dll to the / ext directory, next to / Apache and NOTHING it works. Download each version of Instant Client and NOTHING.

God came to my aid. When I download 32 bits of ORACLE Instant Client, everything works fine. phpinfo () displays oci8 info and my application is working fine.

So, NEVER DECREASE THAT YOUR WINDOWS VERSION IS FREE. The link is between XAMPP and the ORACLE instant client.

+14
source

Simple steps

You need to enable the extension below in php.ini

 ;extension=php_oci8.dll ;extension=php_oci8_11.g.dll 

deleting ";" so the results will be lower:

 extension=php_oci8.dll extension=php_oci8_11.g.dll 

Download Oracle Instant Client: - preferably 32 bits. 32 bits will also work on 64 bits. You can just google: download oracle 32 bit instant client windows. Use client version 11 because extension=php_oci8_11.g.dll will not work with 12. Unzip the package to a location such as C:\Oracle\instantclient_11_2 .

Finally, change the System PATH Environment Variable with the final location, in system variables, not user variables

Then you need to restart the system changes for PATH in order to fully propagate.

If you simply restart XAMPP / WAMP without restarting the computer, the client DLL files (i.e. OCL.dll) will not be downloaded (and not found) by the PHP extension php_oci8_11g.dll .

+6
source

What should be done

  • Whenever you connect to Oracle Database, try using the 32-bit oracle client libraries since XAMP PHP is compiled with 32-bit (although you have a 64-bit Windows machine)
  • Download Oracle Client from Download here

  • Paste it in C: \ instantclient_12_1

  • Then set the path above in the system environment variable
  • Then go to C: \ xampp \ php \ php.ini and uncomment extension = php_oci8_12c.dll
  • Then restart XAMP and it should work without any problems.
+4
source

You need to enable this extension in the php.ini file. See Installing Oracle :

 extension=oci8.so 
+3
source

I installed WAMPServer 2.5 (32-bit) and also encountered an oci_connect error. I also had an Oracle 11g client (32-bit). A common fix I read in other posts was changing the php.ini file in the C: \ wamp \ bin \ php \ php5.5.12 directory, however this never worked for me. Perhaps I misunderstood, but I found that if you change the php.ini file in the C: \ wamp \ bin \ apache \ apache2.4.9 directory, you will get the desired results. The only thing I changed in the php.ini apache file is to remove the semicolon before extension=php_oci8_11g.dll in order to enable it. Then I restarted all the services and now it works! Hope this works for you.

+3
source

enter image description here

Connect XAMPP, WAMP Server to Oracle database using PHP (By - Jaydev)

oci.dll php_oci8.dll php_oci8_11g.dll

Fatal error: call of the undefined oci_connect () function in C: \ xampp \ htdocs \ Fatal error: call of the undefined oci_connect () function in C: \ wampp \ www \

+2
source

Ok guys.

First use

 <?php phpinfo(); ?> 

and define your version of PHP (located at the very top, for example, 7.0.xxx), as well as your architecture of the version of PHP: x64 or x86, as well as Thread Safe or Not THread Safe (located in the first table as "Thread Safety".) Disabled obviously means Unsecured Stream.

It is imperative that you need the following three software components:

  1. for the same major version of PHP (7.0 for 7.0.xxx)
  2. same version of Oracle as the version you are accessing (11g, 12g, etc.)
  3. the same Non-Thread Safe / Thread Safe version of PHP
  4. all on the same architecture.

If any of the following applies to a different architecture, and not to the threaded / threaded / threaded safe version, the main PHP number, or the database version, you will get errors:

  1. PHP for Windows 2. OCI8 PECL Drivers for PHP (https://pecl.php.net/package/oci8) 3. Oracle Instant Client 

Remember: if you are connecting to an Oracle 11g instance, you need the 11g driver.

Secondly , install the correct PHP, OCI8 PECL driver and instant client.

I chose:

 d:\php\ for php d:\oci\ for instant client unzip the contents of the OCI8 PECL Driver into d:\php\ext\ 

Third , change d: \ php \ php.ini according to Oracle instructions:

 1. set the extension directory 2. set only one of the following: a. for 11g drivers, use extension=php_oci8_11g.dll b. for 12c drivers, use extension=php_oci8_12c.dll c. for other oracle DB drivers, use the correct oracle extension. 

Fourth: add d: \ oci \ (or wherever you are at the time of client installation) to your PATH system variable.

Fifth : restart the computer.

Sixth , at the command prompt, enter "where oci *" and make sure that oci.dll is installed in your path to install Instant Client.

Seventh , go to d: \ php \ and type "php -m" and you should see OCI8 in the list.

If you do not see OCI8 in the list of modules after entering "php -m", open d: \ php \ errorlog.txt

If you see something like:

 PHP Warning: PHP Startup: Unable to load dynamic library 'ext\php_oci8_11g.dll' - %1 is not a valid Win32 application. 

then instantly loading the client or your PECL driver is different from the architecture of your version of PHP.

If you see something like:

 PHP Warning: PHP Startup: Unable to load dynamic library 'ext\php_oci8_12c.dll' - The specified procedure could not be found. 

then you are using the wrong OCI8 PECL driver for your client version for instant access.

Hope this helps.

+1
source

I installed Wamp and expected everything to work out of the box. Not this way. I have two Oracle clients on my Windows x64 computer (instant and full). If anyone else has a similar setup, the trick is to make sure that the instant client (a) in the Path environment variable and (b) precedes the full client in the Path variable. There really is a brief section on Windows here , but it gave an answer.

0
source

Well, if anyone encounters this problem at some point in their life, please, this is my story:

  • Windows 10 x64
  • Oracle Express 11g
  • XAMPP 32bits with PHP 7.1.6

    • Download Instant Client Basic 12.1 here (version required by phpinfo () in the Configure command). I downloaded v12.1 for 32 bit (even my computer was x64)
    • Download the Instant Client SDK (which is located on the same site where you download the Instant Client, but scroll down)
    • Copy the downloaded files to the C: C: \ instantclient_12_1 drive , and inside it sdk like C: \ instantclient_12_1 \ SDK
    • Add these two previous routes to the system environment variables (ORACLE_PATH and ORACLE_PIN for the SDK)
    • Uncomment extension = php_oci8_12c.dll and extension = php_pdo_oci.dll in php.ini (C: \ xampp \ php \ php.ini) by removing the half ring in front of it.
    • Restart your computer because you changed your system variables (and thus XAMPP will also restart)

PS: Two days of my life to get to this.

Greetings

0
source

try this

in php.ini file uncomment this

extension_dir = "./" "delete semicolon"

0
source

I had the same problem, the solution on this page helped me, caused by using incompatible oci ddl files.

Hope it helps.

0
source
  • Download the xampp extension and uncomment the oracle 12c or the 11c = oci8_11g extension for xampp 7.2.9.
  • Download 32 bit instant client and set its path
  • Download the 32-bit Instant Client SDK and specify its path
  • Copy instant clients and dll SDK files to xamp \ php \ ext, xampp \ php \ and xampp \ appache \ bin \
  • Download php-oci of the same php version of tread safe x86, then copy its files to php \ ext * .dll, the php version is written on top of the xampp admin phpinfo tab.
  • OCI8 appears on the phpadmin page or at the apache administrator, then on the phpadmin tab. This means phpOCI has been installed.
0
source
  1. Check your php version as PHP 5.6.32 (cli) (build: October 25, 2017 16:02:15).
  2. Using the OCI8 extension to access an Oracle database. So download php_oci8.dll from 1 https://pecl.php.net/package/oci8/2.0.8/windows . (5.6 Thread Safe (TS) x86) php_oci8.dll must be the same version as your php version. Then unzip it and you will find 1.php_oci8.dll 2.php_oci8_11g.dll (according to your oral version), these two files are inserted into your
    (xampp \ php \ ext) folder.

  3. Open the php.ini file and add these extensions = php_oci8.dll extension = php_oci8_11g.dll

  4. Check your oracle version and service name using these commands

    1. Open your cmd
    2. sqlplus / as sysdba
    3. select * from version v $; Oracle Database 11g Enterprise Edition release 11.2.0.1.0 is production, our version of oracle is 11g, so we can use InstantClient_11_1 (Instant Client 32-bit) to download from https://www.oracle.com/technetwork/topics/ winsoft-085727..html
  5. show parameter service_name; service_name is orcl (you must remember this service name)

  6. After downloading, InstantClient_11_1 unzipped it and then inserted it into the local drive. And copy the path C: \ instantclient_11_1, and then set this path as a user variable and a system variable. Please note that my code works without setting the path variable.

  7. Open your cmd and enter SQL, create a schema by following these commands

    1. sqlplus / as sysdba
    2. create the db username identified by pass123;
    3. Provide a connection, a resource for dbname;

    4. Create a user_info table, insert the data into your table and commit. Note: you must commit your data, otherwise the data will not be inserted.

    5. Then this script runs in your htdocs

 <html> <head><title>Oracle demo</title></head> <body> <?php // Create connection to Oracle $conn = oci_connect("dbname", "pass123", "//localhost/orcl"); // orcl is your service_name $query = 'select * from user_info'; $stid = oci_parse($conn, $query); $r = oci_execute($stid); // Fetch each row in an associative array print '<table border="1">'; while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) { print '<tr>'; foreach ($row as $item) { print '<td>'.($item !== null ? htmlentities($item, ENT_QUOTES) : '&nbsp').'</td>'; } print '</tr>'; } print '</table>'; 
0
source

enter image description here

Setting the NLS_LANG Environment Variable for Oracle Databases (By - Jaydev) Follow this procedure to set the NLS_LANG environment variable for Oracle Databases. To set the NLS LANG environment variable for Oracle databases

-3
source

All Articles