Oracle 11.1.0.7 and WAMP oci_connect failure

2020-04-10 04:42发布

I'm trying to configure a simple connection between my local WAMP server and some Oracle 11.1.0.7 I have. Apparently PHP has all sorts of solutions and magic situations where it fails to start.

I'm running the latest 32bit version from WAMP (I fetched it today again just to check) The db machine is also 32bit, not local

here are my attempts in connecting to the database, everytime I got the same error :

    $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = some.ip.addr)(PORT = 1521)))(CONNECT_DATA=(SID=somesid)))";
    //$link = oci_connect('sqlmap', 'sqlmap', 'some.ip.addr') OR die('oci_connect' . print_r(oci_error()));
    //$link = oci_connect('sqlmap', 'sqlmap', $db) OR die('oci_connect error' . print_r(oci_error()));
    //$link = oci_connect('sqlmap','sqlmap', 'some.ip.addr/somesid') or die('<= oci_connect ' . print_r(oci_error()));
    //$link = oci_connect('sqlmap','sqlmap', '//some.ip.addr/somesid') or die('<= oci_connect ' . print_r(oci_error()));
    $link = oci_connect('sqlmap','sqlmap', '//some.ip.addr/somesid');

Warning: oci_connect() [function.oci-connect]: ORA-24315: illegal attribute type in


Array ( [code] => 24315 [message] => ORA-24315: illegal attribute type [offset] => 0 [sqltext] => ) oci_connect1

Some more information regarding OCI

OCI8 Support    enabled
Version 1.4.7
Revision    $Revision: 321634 $
Active Persistent Connections   0
Active Connections  0
Oracle Run-time Client Library Version  10.2.0.1.0
Oracle Instant Client Version   11.2
Temporary Lob support   enabled
Collections support enabled

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


Apache Version :
2.2.21  
PHP Version :
5.3.9

I would be fond if anyone could hint me what I might be missing

2条回答
We Are One
2楼-- · 2020-04-10 05:08
  1. execute "phpinfo()";
  2. in "Configure Command", you will see something like: "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" ... till now ok!
  3. download Oracle "Instant Client for Microsoft Windows 32-bit" and your "SDK" from http://www.oracle.com/technetwork/topics/winsoft-085727.html , even if your Windows is 64-bit: 3.1 download "Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications: instantclient-basic-win32-11.1.0.7.0.zip" 3.2 download "*Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client: instantclient-sdk-win32-11.1.0.7.0.zip" 3.4 unpack two zip in same folder, you will see SDK into folder of instantclient_11 after unpacked; till here OK!
  4. copy this unpacked folder to C:\Windows\SysWOW64\instantclient_11_1
  5. create C:\php-sdk\oracle\instantclient11, and copy the content of C:\Windows\SysWOW64\instantclient_11_1 to C:\php-sdk\oracle\instantclient11
  6. Now, ADD to Windows Environment Variable PATH the follow: "C:\Windows\SysWOW64\instantclient_11_1"
  7. And finally, open Wamp and enable php_oci8_11g extension
  8. Check "phpinfo()" again; It works! Why??? Because C:\wamp\bin\php\php5.3.13\ext\php_oci8_11g.dll or C:\wamp\bin\php\php5.3.13\ext\php_oci8.dll are 32-bit DLLs; into 64-bit environment, when your Windows needs a 32-bit version of "Oracle Instant Client", it will seek into C:\Windows\SysWOW64 .
查看更多
不美不萌又怎样
3楼-- · 2020-04-10 05:09

Looking at your configuration, you have both the Oracle Client and the Oracle Instant Client installed:

Oracle Run-time Client Library Version  10.2.0.1.0
Oracle Instant Client Version   11.2

However, my experience is that PHP will only use one or the other - basically, whichever set of libraries is found first will get used. Since you can connect fine to Oracle 10g, but not to 11g, that suggests that the 10g Client Library is "higher" in your path than the Instant Client libraries.

Two options I'd suggest exploring:

  1. Install the full Oracle 11g Client
  2. Specifically alter your path to ensure that the Instant Client libraries are found first - making sure, of course, that you are impacting the effective path used by PHP, not just a PATH variable in a separate context...

I've never actually got PHP to work correctly with the Instant Client - I gave up and installed the full client - so my personal recommendation is option 1, but if that's not practical in your environment, work with the PATH first.

查看更多
登录 后发表回答