Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'c:/wamp64/bin/php/php7.0.10/ext/php_oci8_12c.dll' - %1 is not a valid win32 application

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?

like image 494
terminator Avatar asked Dec 18 '22 10:12

terminator


1 Answers

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!

like image 156
Luiz Vaz Avatar answered Jan 06 '23 03:01

Luiz Vaz