user3891365 user3891365 - 1 month ago 17
PHP Question

install and configure OCI8 to connect oracle to php

I installed oracle 11g and I did create some tables and manipulate it using sql developer, and I am looking for a way to connect oracle with php on hosting site.

I tried but I get error after using this code:

$Conexion_ID =oci_connect($OracleUser, $OraclePassw, $OracleIP);


this is the error:

Call to undefined function oci_connect()


I've known that I should install and configure OCI8, so I downloaded this file:

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

but I don't know in which folder should I them to make the connection work well.

Answer

Download the PHP Extension from here(Confirm the PHP Version and download for the same, the thread safe[TS] version): http://pecl.php.net/package/oci8/2.0.8/windows

You should be able to find three .dll's

php_oci8.dll, php_oci8_11g.dll and php_oci8_12c.dll

Place all dll's in extension directory, in WAMP it is generally wamp\bin\php\php5.*.*\ext

open the php configuration from the System try of wamp server and add the line:

; Enable only which is required
;extension=php_oci8.dll
extension=php_oci8_11g.dll 
;extension=php_oci8_12c.dll

Restart the Apache server.

EDIT : Sorry I thought the other dll's are the libraries, but instead they are for different oracle versions. In your case enable 11g. Answer updated.

Update 2016-11-07: just wanted to say that latest package can be found here https://pecl.php.net/package/oci8. When I wrote this answer 2.0.8 was latest i guess.