3
votes

I want to connect to my oracle database, but i have a problem with function oci_connect. i have tried to uncomment this:

extension=php_oci8.dll 

but, still have an error :

Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\testing\db.php on line 71

But, when i check in phpinfo(), oci8 still not loaded and i can not connect to my oracle database. i already restart my apache. How i fix this problem ? Canyou help me?

Thank you..

4
Is an Oracle client installed? Have you read the requirements and followed the installation instructions? - timclutton
of course yes. previously i use xampp version 1.6.4 and it works fine. now i upgrade my xampp into version 5.5.30 but i got that error. can you help me to fix this problem? - allrise
Check that php_oci8.dll exists in the ext folder. Check the php_errors.log file for startup errors and edit your question to include any information from there. - timclutton
Also, try following the steps in a previous answer of mine. - timclutton
php_oci8.dll exists in ext folder. when i cek the php_error_log, i got this : "[10-Dec-2015 10:01:14 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_oci8.dll' - The specified procedure could not be found." . why can not load the php_oci8.dll ? whereas php_oci8.dll is existing in ext folder .. confused~~ - allrise

4 Answers

2
votes

In Ubuntu 16.04, using PHP 5.6, with 64bit os, try this:

Install the packages:

sudo apt-get install php5.6-dev build-essential php-pear libaio1

Download the latest version of the packages from:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Search for these packages, according with the latest version:

oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm

Converting packages:

sudo apt-get install alien
sudo alien oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
sudo alien oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm

Installing:

sudo dpkg -i oracle-instantclientXX.X-basic_XX.X.X.X.X-X_amd64.deb
sudo dpkg -i oracle-instantclientXX.X-devel_XX.X.X.X.X-X_amd64.deb

Installing oci8:

sudo pecl install oci8-2.0.12

*Build process completed successfully
Installing '/usr/lib/php/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini*

Add the extension to php:

sudo gedit /etc/php/5.6/apache2/php.ini

add the extension:

extension=oci8.so

Restart apache:

sudo service apache2 restart

That's it.

1
votes

In php.ini ensure that you enable the correct OCI extension (11g), like this:

;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client

As long as you've got Oracle 11gR2 or greater client libraries correctly installed you should now be able to run:

C:\>php --ri oci8

And get the result:

oci8

OCI8 Support => enabled
Version => 1.4.10
Revision => $Id: b0984d94e17f7c099470cd0a9404259f2a59da04 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Instant Client Version => 11.2
Temporary Lob support => enabled
Collections support => enabled

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

To check your Oracle client is installed correctly (i.e., in your environment PATH variable) you can run:

C:\>where oci*

You should get a result like this:

C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym
0
votes

Follow the offcial link for me Oracle

http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html

Here is what worked with Xammp

1.uncomment extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client if you are using 11g (in php.ini)

2.add AddHandler fcgid-script .php to httpd.conf

3.Download the FastCGI component mod_fcgid-2.3.6-win32-x86.zip from httpd.apache.org/download.cgi#mod_fcgid

4.Unzip it to the installed Apache 2.2 directory. The C:\xamp\apache\modules directory should now have mod_fcgid.so and mod_fcgid.pdb files.

5.Download the "Instant Client Package - Basic" for Windows from the OTN Instant Client page. Because PHP is 32 bit, use the 32 bit version of Instant Client.

Unzip the Instant Client files to C:\instantclient_11_2

Edit the Windows PATH environment setting and add C:\instantclient_11_2. For example, on Windows XP, follow Start -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.

Commonly you need to reboot Windows so the new environment is correctly set.

that worked for me all the best

0
votes

Have a look at RO_engineer's answer of installing x86 files of Oracle insta client rather than x64 version. It resolved my issue, may be that can help you too.

https://stackoverflow.com/a/27177616/289587

Download Instant Client for Microsoft Windows (32-bit)