OCI8 on PHP with Oracle 9i

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chad The Man

    OCI8 on PHP with Oracle 9i

    I have been developing some applications on suse 9 / apache 1.37 / php
    4.3.4 / Oracle 9i / OCI8. We recently moved servers, apache works
    fine, php works fine, oracle works fine... however, trying to connect
    to oracle from php it dies with the following error :

    Warning: ocilogon(): _oci_open_sessi on: OCIHandleAlloc
    OCI_HTYPE_SVCCT X: OCI_INVALID_HAN DLE

    Using SQL plus I can connect just fine. The variables are all set in
    apache and the connection string... the permissions on the oracle
    folder are all correct.

    HELP!!! Thank you in advance.
  • Andy Hassall

    #2
    Re: OCI8 on PHP with Oracle 9i

    On 7 Jan 2004 16:08:06 -0800, csollis@oversto ck.com (Chad The Man) wrote:
    [color=blue]
    >I have been developing some applications on suse 9 / apache 1.37 / php
    >4.3.4 / Oracle 9i / OCI8. We recently moved servers, apache works
    >fine, php works fine, oracle works fine... however, trying to connect
    >to oracle from php it dies with the following error :
    >
    >Warning: ocilogon(): _oci_open_sessi on: OCIHandleAlloc
    >OCI_HTYPE_SVCC TX: OCI_INVALID_HAN DLE
    >
    >Using SQL plus I can connect just fine.[/color]

    So the Oracle install is (probably) OK (assuming you're using the same Oracle
    home that you're trying to use with PHP).
    [color=blue]
    > The variables are all set in apache[/color]

    Are you _sure_? Could you post the output of:

    <pre>
    <?php
    echo $_ENV['ORACLE_HOME'] . "\n";
    echo $_ENV['LD_LIBRARY_PAT H'] . "\n";
    echo $_ENV['PATH'] . "\n";
    ?>
    </pre>
    [color=blue]
    >and the connection string...[/color]

    Doesn't look it's got far enough for that to matter yet.
    [color=blue]
    >the permissions on the oracle folder are all correct.[/color]

    Are you _sure_? Post the output of (from a shell):

    ls -ld $ORACLE_HOME
    ls -ld $ORACLE_HOME/bin
    ls -ld $ORACLE_HOME/lib*

    The error you've posted usually comes from:

    (a) Environment variables not set or wrong.

    (b) ORACLE_HOME set to a different home to the one that PHP was compiled
    against, e.g. mixing up 8i and 9i.

    (c) ORACLE_HOME not accessible by webserver - 9i default permissions are
    stricter than 8i.

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • Chad The Man

      #3
      Re: OCI8 on PHP with Oracle 9i

      Andy, Thanks for the follow up so quickly. We are using the same
      oracle home for the php. in the phpinfo page php is setup for oracle
      home in the right place as well on the oci8 display. The output of
      your suggestions were as follows:

      The output of the first was discouraging:
      ORACLE HOME:
      LD_LIBRARY_PATH : . :/lib
      PATH: /usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin

      Nothing returned for oracle home.
      The output from the shell was correct for all.

      I have these lines of code in the httpd.conf file just under the
      AddModule Section:

      SetEnv ORACLE_HOME /opt/oracle/OraHome1
      SetEnv LD_LIBRARY_PATH /opt/oracle/OraHome1/lib
      SetEnv TNS_ADMIN /opt/oracle/OraHome1/tnsnames.ora
      SetEnv TWO_TASK /opt/oracle/OraHome1/tnsnames.ora
      SetEnv NLS_LANG English_America .WE8ISO8859P1
      SetEnv ORACLE_BASE /opt/oracle/OraHome1

      Any suggestions?

      Thanks for your help


      Andy Hassall <andy@andyh.co. uk> wrote in message news:<759pvvknk 3mbpj1h6paci9e9 eed7al1lpm@4ax. com>...[color=blue]
      > On 7 Jan 2004 16:08:06 -0800, csollis@oversto ck.com (Chad The Man) wrote:
      >[color=green]
      > >I have been developing some applications on suse 9 / apache 1.37 / php
      > >4.3.4 / Oracle 9i / OCI8. We recently moved servers, apache works
      > >fine, php works fine, oracle works fine... however, trying to connect
      > >to oracle from php it dies with the following error :
      > >
      > >Warning: ocilogon(): _oci_open_sessi on: OCIHandleAlloc
      > >OCI_HTYPE_SVCC TX: OCI_INVALID_HAN DLE
      > >
      > >Using SQL plus I can connect just fine.[/color]
      >
      > So the Oracle install is (probably) OK (assuming you're using the same Oracle
      > home that you're trying to use with PHP).
      >[color=green]
      > > The variables are all set in apache[/color]
      >
      > Are you _sure_? Could you post the output of:
      >
      > <pre>
      > <?php
      > echo $_ENV['ORACLE_HOME'] . "\n";
      > echo $_ENV['LD_LIBRARY_PAT H'] . "\n";
      > echo $_ENV['PATH'] . "\n";
      > ?>
      > </pre>
      >[color=green]
      > >and the connection string...[/color]
      >
      > Doesn't look it's got far enough for that to matter yet.
      >[color=green]
      > >the permissions on the oracle folder are all correct.[/color]
      >
      > Are you _sure_? Post the output of (from a shell):
      >
      > ls -ld $ORACLE_HOME
      > ls -ld $ORACLE_HOME/bin
      > ls -ld $ORACLE_HOME/lib*
      >
      > The error you've posted usually comes from:
      >
      > (a) Environment variables not set or wrong.
      >
      > (b) ORACLE_HOME set to a different home to the one that PHP was compiled
      > against, e.g. mixing up 8i and 9i.
      >
      > (c) ORACLE_HOME not accessible by webserver - 9i default permissions are
      > stricter than 8i.[/color]

      Comment

      • Andy Hassall

        #4
        Re: OCI8 on PHP with Oracle 9i

        On 8 Jan 2004 10:45:10 -0800, csollis@oversto ck.com (Chad The Man) wrote:
        [color=blue]
        >Newsgroups: comp.lang.php
        >
        >Andy, Thanks for the follow up so quickly. We are using the same
        >oracle home for the php. in the phpinfo page php is setup for oracle
        >home in the right place as well on the oci8 display. The output of
        >your suggestions were as follows:
        >
        >The output of the first was discouraging:
        >ORACLE HOME:
        >LD_LIBRARY_PAT H: . :/lib
        >PATH: /usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
        >
        >Nothing returned for oracle home.
        >The output from the shell was correct for all.
        >
        >I have these lines of code in the httpd.conf file just under the
        >AddModule Section:
        >
        >SetEnv ORACLE_HOME /opt/oracle/OraHome1
        >SetEnv LD_LIBRARY_PATH /opt/oracle/OraHome1/lib
        >SetEnv TNS_ADMIN /opt/oracle/OraHome1/tnsnames.ora
        >SetEnv TWO_TASK /opt/oracle/OraHome1/tnsnames.ora
        >SetEnv NLS_LANG English_America .WE8ISO8859P1
        >SetEnv ORACLE_BASE /opt/oracle/OraHome1[/color]

        I don't think SetEnv does what you think it does. It adds to the environment
        for subprocesses spawned by Apache, i.e. CGI, but I don't think it affects the
        Apache process itself - since PHP (usually) runs as a module then it's not
        going to see this environment.

        Set the environment variables in your Apache startup script, before you start
        Apache itself, or use putenv in your PHP script.

        Also I don't think your TNS_ADMIN and TWO_TASK are correct? TNS_ADMIN is the
        directory in which tnsnames.ora can be found, isn't it? And TWO_TASK can be set
        to the TNS alias you want to connect to by default - not the path to the
        tnsnames.ora file?

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

        Comment

        Working...