Symptoms:

Fatal error on any oci-connect() from PHP5. Seems to be local config issue but PHP shows OCI8/instant client installed. Never establishes connection, our database admin confirms no activity in the Oracle logs tracing our IP/hostname, and also we can telnet to the Oracle server on port 1521 from ours.

Platform:

Linux RHEL5 Enterprise
Oracle 11G (remote)
PHP 5.3.2
Oracle Instant Client 11.2
OCI8 1.4.1
VMWare guest on a Dell host (details not known)
We are not using connection pooling with 11G

PHP showing OCI installed (same as you'd see in phpinfo):

[root@mbda-portaldev mbda]# php --ri oci8

oci8

OCI8 Support => enabled
Version => 1.4.1
Revision => $Revision: 294447 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Instant Client Version => 11.2
Temporary Lob support => enabled
Collections support => enabled

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

Testing code I am using to establish connection:

<?php

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'On');

oci_internal_debug(1);

print "\nStarting\n\n";

$conn=oci_connect('user', 'password','//10.x.x.x:1521/PYTHIA.MBDA-DBPROD');

            $sql="select * from table";

$s=oci_parse($conn,$sql);
oci_execute($s, OCI_DEFAULT);

print "\n\nFinished\n";

?>

Output of above script (always stops at same line):

Starting

OCI8 DEBUG: OCINlsEnvironmentVariableGet at (/opt/php-5.3.2/ext/oci8/oci8.c:1811) 
OCI8 DEBUG L1: Got NO cached connection at (/opt/php-5.3.2/ext/oci8/oci8.c:1856) 
OCI8 DEBUG: OCIEnvNlsCreate at (/opt/php-5.3.2/ext/oci8/oci8.c:2809) 
OCI8 DEBUG: OCIHandleAlloc at (/opt/php-5.3.2/ext/oci8/oci8.c:2620) 
OCI8 DEBUG: OCIHandleAlloc at (/opt/php-5.3.2/ext/oci8/oci8.c:2632) 
OCI8 DEBUG: OCIHandleAlloc at (/opt/php-5.3.2/ext/oci8/oci8.c:2649) 
OCI8 DEBUG: OCIAttrSet at (/opt/php-5.3.2/ext/oci8/oci8.c:2669) 
OCI8 DEBUG: OCIAttrSet at (/opt/php-5.3.2/ext/oci8/oci8.c:2678) 
OCI8 DEBUG: OCISessionPoolCreate at (/opt/php-5.3.2/ext/oci8/oci8.c:2690)

Note: That's where it stops. It never actually connects. I could change the datasource to "//foobar" and it would do the same.

Help, please!

-jim

    I use this function when connecting to our oracle server, 11g, at work

    function oracle_connect()
    {
      $user='abcde';
      $pwd='password';
      $server='servername'; // or ip
      $port='1521';
      $sid='orcl'; // service name
      $charset='WE8ISO8859P1'; // change to whatever is needed
    
      $conn=oci_connect($user,$pwd,'//'.$server.':'.$port.'/'.$sid,$charset);
    
      if (!conn)
      {
        $e=oci_error();
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
        return FALSE;
      }
      else
        return $conn;
    }

    I have a Ubuntu 10.04 as a web server, and i followed this guide http://ubuntuforums.org/showpost.php?p=3973961&postcount=25 to set up oci (only need to change the version numbers to whatever is current), perhaps it can be of some use, even if its different distros.

      Thank you much for your help. We installed it similarly with the same libraries but for Red Hat, and like I noted above PHP shows OCI8 as installed, no errors during compiling. Even your test code results in a fatal error - the debugging output is exactly the same, stopping at the same place.

      I just tried newer minor version of PHP and OCI8 1.4.2 from PECL - no luck either, same results exactly.

      In all installations, PHP ignores whatever I use for datasource in oci_connect(), it fatal errors, never makes a connection. I'm asking folks reading this to please examine the debugging output I posted and maybe explain why it might be stopping there? It might help me isolate what we did wrong on the installation or if its an environment issue in Red Hat or VMWARE.

      -jim

        8 days later

        Re-installed with OCI8 1.4.3 on PHP 5.3.2 - PHPINFO shows installed, no compile errors, but it won't connect. It bombs during debugging at this line, always:

        OCI8 DEBUG: OCISessionPoolCreate at (/opt/php-5.3.2/ext/oci8/oci8.c:2690)

        Why?

          I never found out exactly the culprit, but on our VM Ware we loaded an older snapshot which had PHP 5.2.10 instead of 5.3.2 and Instant Client 11.1 instead of 11.2 which was installed via RPM instead of being referenced by source from the zip download, an alternative install method.

          This configuration works and survived cloning too. For the record, I am still mystified why PHP stopped all the time on that OCI debug line. One guess is a Red Hat update fudged things with that specific configuration, but at this point we're happy to get it working so we're moving fwd.

          Forgot to mention -- marked as resolved.

            Write a Reply...