By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

OCI8 on PHP with Oracle 9i

P: n/a
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_session: OCIHandleAlloc
OCI_HTYPE_SVCCTX: OCI_INVALID_HANDLE

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.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 7 Jan 2004 16:08:06 -0800, cs*****@overstock.com (Chad The Man) wrote:
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_session: OCIHandleAlloc
OCI_HTYPE_SVCCTX: OCI_INVALID_HANDLE

Using SQL plus I can connect just fine.
So the Oracle install is (probably) OK (assuming you're using the same Oracle
home that you're trying to use with PHP).
The variables are all set in apache
Are you _sure_? Could you post the output of:

<pre>
<?php
echo $_ENV['ORACLE_HOME'] . "\n";
echo $_ENV['LD_LIBRARY_PATH'] . "\n";
echo $_ENV['PATH'] . "\n";
?>
</pre>
and the connection string...
Doesn't look it's got far enough for that to matter yet.
the permissions on the oracle folder are all correct.


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 (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2

P: n/a
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 <an**@andyh.co.uk> wrote in message news:<75********************************@4ax.com>. ..
On 7 Jan 2004 16:08:06 -0800, cs*****@overstock.com (Chad The Man) wrote:
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_session: OCIHandleAlloc
OCI_HTYPE_SVCCTX: OCI_INVALID_HANDLE

Using SQL plus I can connect just fine.


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


Are you _sure_? Could you post the output of:

<pre>
<?php
echo $_ENV['ORACLE_HOME'] . "\n";
echo $_ENV['LD_LIBRARY_PATH'] . "\n";
echo $_ENV['PATH'] . "\n";
?>
</pre>
and the connection string...


Doesn't look it's got far enough for that to matter yet.
the permissions on the oracle folder are all correct.


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.

Jul 17 '05 #3

P: n/a
On 8 Jan 2004 10:45:10 -0800, cs*****@overstock.com (Chad The Man) wrote:
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_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


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 <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.