title: oci_connect connection failed
body: <p>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 <code>phpinfo()</code>).</p>
  
  <p>I have tried many connection options (listed below) with the same error returned:</p>
  
  <pre><code>oci_connect(): ORA-28547: connection to server failed, probable Oracle Net admin error
  </code></pre>
  
  <p>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...</p>
  
  <p>I have set environment variable <code>TNS_ADMIN</code> to <code>c:\oracle_instantclient_11_2</code> where the file <code>tnsnames.ora</code> is located containing this connection description:</p>
  
  <pre><code>MYDB =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X)(PORT = 1521))
      )
      (CONNECT_DATA = (SID = MYDB)(SERVER = DEDICATED))
    )
  </code></pre>
  
  <p>Using this description like</p>
  
  <pre><code>(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))
  </code></pre>
  
  <p>I am able to connect to the server and the service/database with <code>sqlplus</code> console, so the connection is very right. I am also using the very same HOST, PORT and SID to connect to the server with <code>Sqldeveloper</code> tool. The problem is when connecting to the server within a PHP...</p>
  
  <p>What have I tried so far:</p>
  
  <pre><code>oci_connect("user", "password", "X.X.X.X:1521", "AL32UTF8", 0);
  oci_connect("user", "password", "MYDB", "AL32UTF8", 0);
  oci_connect("user", "password", "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))", "AL32UTF8", 0);
  </code></pre>
  
  <p>All of these <code>oci_connect</code> calls above return the same error mentioned.</p>
  
  <p>I had also tried the <code>ezconnect</code> way for 11g as stated <a href="http://php.net/manual/en/function.oci-connect.php" rel="nofollow noreferrer">here</a> - <code>[//]host_name[:port][/service_name][:server_type][/instance_name]</code>:</p>
  
  <pre><code>oci_connect("user", "password", "X.X.X.X:1521/MYDB", "AL32UTF8", 0);
  </code></pre>
  
  <p>but the problem is I do not know the <code>service name</code>, only the <code>service ID</code> (<code>SID</code>), thus the error returned is this:</p>
  
  <pre><code>oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
  </code></pre>
  
  <p>that says there is no service running with the service name provided (or that the ORA listener does not know of such service).</p>
  
  <p>PHP version: 5.3.14<br />
  Appache v.: 2.2.22 (32bit) Zend<br />
  Zend server CE: 5.3.6</p>
  
  <p>PHP info for OCI8:</p>
  
  <pre><code>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
  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
  </code></pre>
  
  <p>Maybe the problem is that there is <code>unknown</code> version of <code>Oracle instant client</code> though it's path is set within both the <code>TNS_ADMIN</code> and <code>PATH</code> environment variables...</p>
  
  <p><strong>My question is:</strong> 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...</p>
  
  <p>Though this question could be considered as an exact duplicate <a href="https://stackoverflow.com/questions/9099158/oracle-11-1-0-7-and-wamp-oci-connect-failure">of this one</a> - 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. <strong>Also keep in mind that in that similar question a different error is returned and asked about.</strong></p>