shadyyx shadyyx - 1 year ago 102
PHP Question

oci_connect connection failed

I am having serious problem connecting to external ORA DB 11g from local Zend server CE.
OCI8 is enabled and running version 1.4.6 (due to


I have tried many connection options (listed below) with the same error returned:

oci_connect(): ORA-28547: connection to server failed, probable Oracle Net admin error

After googling for whole day I am only able to say that this error means that PHP was able to comunicate with the server but was unable to connect to a concrete service/database and that the error shouldn't come from PHP itself...

I have set environment variable
where the file
is located containing this connection description:


Using this description like


I am able to connect to the server and the service/database with
console, so the connection is very right. I am also using the very same HOST, PORT and SID to connect to the server with
tool. The problem is when connecting to the server within a PHP...

What have I tried so far:

oci_connect("user", "password", "X.X.X.X:1521", "AL32UTF8", 0);
oci_connect("user", "password", "MYDB", "AL32UTF8", 0);

All of these
calls above return the same error mentioned.

I had also tried the
way for 11g as stated here -

oci_connect("user", "password", "X.X.X.X:1521/MYDB", "AL32UTF8", 0);

but the problem is I do not know the
service name
, only the
service ID
), thus the error returned is this:

oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

that says there is no service running with the service name provided (or that the ORA listener does not know of such service).

PHP version: 5.3.14

Appache v.: 2.2.22 (32bit) Zend

Zend server CE: 5.3.6

PHP info for OCI8:

OCI8 Support enabled
Version 1.4.6
Revision $Revision: 313688 $
Active Persistent Connections 0
Active Connections 0
Oracle Instant Client Version Unknown
Temporary Lob support enabled
Collections support enabled

Directive Local Value Master Value
oci8.connection_class no value no value
oci8.default_prefetch 100 100 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

Maybe the problem is that there is
version of
Oracle instant client
though it's path is set within both the
environment variables...

My question is: does anybody know of what have I done wrong? Am I missing something? I have googled for a whole day yesterday so probably (with 99% chance) any google links You would like to provide me with I have already seen and tried...

Though this question could be considered as an exact duplicate of this one - it has not been yet answered and I guess nobody will return back to that old question even if I post a comment I am having the connection problems too. Also keep in mind that in that similar question a different error is returned and asked about.

Answer Source

Due to several misconfigurations and 3 days lost while looking for a solution I moved to develop on Linux server and all of the problems are gone.

What I have found:

  • both php_oci8.dll and php_oci8_11g.dll are depending on the Oracle Instant Client libraries
    • these libraries does not contain oci_ functions (like oci_connect), only ociX functions (like ociLogon) which is strange...
  • though I am pretty sure I have downloaded Oracle Instant Client Basic and all of the extensions, I was not able to connect to another Oracle server due to unknown charset and the error was saying I am using only Lite instant client...
  • I tried both 64bit and 32bit instant client version at no avail
  • my Apache is 64bit, windows is 64bit, PHP is 32bit, remote Oracle server is 64bit, remote Linux server is 64bit...
  • tried many environment settings (ORA_HOME, TNS_ADMIN, adjusted PATH to look to instant client installation) at no avail
  • tried uninstalling local Oracle XE server due to possible environment settings interference at no avail
  • almost lost my head - at no avail...

So finaly on Linux server I have no problems connecting to remote Oracle server. Somewhere (while surfing over thousands of PHP-Oracle related pages) I have found an information that "one shouldn't develop PHP application connecting to Oracle server under windows" and should stick to UNIX system instead...

So anybody experiencing similar or same problems - be so kind and do not waste Your time, install a VirtualBox, run Linux on it and move forward!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download