5

In order to access an remote Oracle database from php, I had to activate the extension php_oci8_12c. But when I do, it does not appear in the phpinfo(). On the other hand, I get in the php logs the error message:

[13-Jan-2017 08:39:48 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.0.10/ext/php_oci8_12c.dll' - %1 is not a Valid win32 application

I use php 5.6.25 and wampserver 3.0.6 (64 bit). How can I resolve this?

terminator
  • 51
  • 1
  • 6
  • Looks like you mixed 32-bit and 64-bit. Is your php also 64 bit? – Wernfried Domscheit Jan 13 '17 at 10:38
  • I installed wamp 64 bits, I guess it provided me a 64 bit php – terminator Jan 13 '17 at 10:51
  • 1
    I assume you have to install also an Oracle Client. Did you do that (Oracle 12c, also 64 bit!) – Wernfried Domscheit Jan 13 '17 at 10:53
  • I would like to access a remote database oracle 9i 64-bit, and on my pc, I have sqlplus 9.2.0.1.0 32 bit – terminator Jan 13 '17 at 11:11
  • 1
    Maybe your wamp/php requires an Oracle Client - for sure it has to be the 64-bit version in this case. Oracle 9i has been phased out 15 years ago, connecting to a 9i Database with a 12c Client is not guaranteed - most likely it will not work. – Wernfried Domscheit Jan 13 '17 at 11:40
  • I just installed the oracle instant. but now, i have this error message when i start wamp "The procedure entry point OCILobRead2 could not be located in the dynamic link library OCI.dll" and then ""php Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.5.12/ext/php_oci8_11g.dll' - The specified module could not be found" ps: i also changed my wamp version to wamp 2.5 32 bit – terminator Jan 13 '17 at 17:30
  • I finally found what was wrong May be a conflict issue between the Oracle clients on my machine. AnyWay, to solve the problem, I changed the position of Oracle Instant Client in the PATH to put it at the beginning of chain – terminator Jan 16 '17 at 08:31

1 Answers1

12

Well, I faced this error too and managed to fix it.

Before downloading every kind Oracle Client Version just take a look at your http://localhost/?phpinfo settings at Configure Command section.

This will tell, which version of Oracle was used to build your WAMP server.

WAMP 3.0.6 PHPINFO

The image above show this two lines:

"--with-pdo-oci=c:\php-sdk\oracle\x64\instantclient_12_1\sdk,shared"
"--with-oci8-12c=c:\php-sdk\oracle\x64\instantclient_12_1\sdk,shared"

Obviously tell us that InstantClient used is 64 bits.

There are two versions of InstantClient 12.1 x64: 12.1.0.2.0 and 12.1.0.1.0

I tested with 12.1.0.2.0 version and failed.
After that, I tested with old one, 12.1.0.1.0 version and worked.

Download from Instant Client for Microsoft Windows (x64) and extract the files below to "c:\oracle":

  • instantclient-basic-windows.x64-12.1.0.2.0.zip
  • instantclient-sqlplus-windows.x64-12.1.0.2.0.zip
  • instantclient-sdk-windows.x64-12.1.0.2.0.zip

This will create the following folder "C:\Oracle\instantclient_12_1".
Using "Windows Command Prompt" (WIN+R CMD) go to folder above and execute SQLPLUS:

  • sqlplus [user]/[pass]@[host]:[port]/[service]

You must be able to connect.

Finally, add the "C:\Oracle\instantclient_12_1" folder to the PATH enviroment variable, placing it on the leftmost place.

Close your WAMP server.

Yes close it, because the Enviroment Variable is only read at launch time.
So restarting the services may fail, leading you to a wrong result.

After restart, your PHPINFO would show the OCI8 and PDO_OCI loaded.

OCI8 PDO_OCI

I hope it helps!

Luiz Vaz
  • 1,669
  • 1
  • 19
  • 32
  • 4
    This should be added to the guide at php.net. Great answer, I have searched far and wide for this, for a while. Thanks! – Wachaga Mwaura Jul 24 '18 at 21:46
  • 2
    Thank you so much! This is what worked for me too after trying lots of other methods. I am using AppServ on Windows 10. – Steve Lloyd Aug 02 '18 at 14:30
  • 1
    Seriously amazing. Yes this worked for me also. If you're using the default XAMPP for 64bit (as of Nov 13th, 2019), you'll need to use the 64bit version of the 12.10.10 (As opposed to the 12.10.20 version) Instant Client which isn't officially listed on the download page. I edited the URL and found it here: https://download.oracle.com/otn/nt/instantclient/121010/instantclient-basic-windows.x64-12.1.0.1.0.zip – ZettaGeek Nov 14 '19 at 04:22