can not load oci8 -> Fatal error: Call to undefined function oci_connect()
Solution 1
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.
Solution 2
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
Admin
Updated on July 02, 2021Comments
-
Admin almost 3 years
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..