PHP Warning at startup while trying to load php_oc

2019-06-20 01:56发布

I'm using XAMPP and trying to configure Oracle connection for sql.

I uncommented the line extension=php_oci8.dll and at first it ended up with an error (that oci.dll is missing), but later I downloaded instantclient from Oracle web pages. I tried with versions 10.2, 11.2, and 12.1 but neither worked. Obviously I've added the path to those libraries to my PATH env variable.

The warning I'm getting at the startup of Apache is: PHP Warning: PHP Startup: in Unknown on line 0

The error when I'm trying to connect is: PHP Fatal error: Call to undefined function oci_connect() in ...

I've tried with php_oci8.dll and php_oci8_11g.dll. Those files are in my php/ext directory (they were included in xampp), my instantclient is added to PATH and the warning doesn't show up if I disable those modules. I've tried restarting services and computer.

Can you help me find a solution how to configure it correctly? I'm using Windows 8.1 with administrative privileges.

BTW. My phpinfo() says that OCI8 is activated (but functions like oci_connect still don't work).

EDIT: When I tried running PHP manually I finally got the error to display what was wrong: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application. in Unknown on line 0 Can you help me find out where can I download a correct version?

标签: php oracle oci
4条回答
The star\"
2楼-- · 2019-06-20 02:03

Its because your Oracle is 64 bit. Remove it and install a 32 bit version of Oracle client and it will work.

查看更多
我想做一个坏孩纸
3楼-- · 2019-06-20 02:12

It looks like your extension are not install properly. Try to update it or reinstall it with pecl with

pecl install extname

You should also check extension_dir directive in php.ini and check if the PHP folder is added to the path

查看更多
手持菜刀,她持情操
4楼-- · 2019-06-20 02:29

There was a problem with 64bit version of instantclient. If you ever have the same issue, please install 32bit version of instantclient.

To be honest the easiest way is just to follow PROPER instructions: http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html

I tried a lot of other advices and they all went really bad on me (not just because I used different bit version - also I copied the files everywhere following stupid advices and it was hard to correct it)

查看更多
在下西门庆
5楼-- · 2019-06-20 02:29

There's an alternate way to solve this: Install the full Oracle Client, not the basic zip, you can get it at oracle site (about 1Gb):

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-windows-3633015.html

Im using Windows 10, Apache 2.4, PHP 7.1 (all x64) and it works. Also tryed PHP 5.6 and it works too. Still use the php_oci8_11g.dll from the basic client zip to match your php and system version.

You can search the site to find older client versions (11g, 32bits, etc) but Im working with de 12c client and accessing an Oracle 11g enterprise server.

I found a lot of occurrencies of this same error all around, but none gave me this solution. Hope taht helps.

查看更多
登录 后发表回答