472,961 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

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_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
3 12526
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
8
by: PIII450 | last post by:
Hi all, We had to switch to windows 2003 server with IIS and now i've got a problem with the OCI8 :(( Big time! I know php works. I have tested this. I know the oracle\bin is in the path. I...
0
by: RDahlstedt | last post by:
I am relatively new to PHP, but with over a decade of experience in C and other programming languages I can usually pick up a new programming language relatively quickly (to be reasonably...
8
by: YeCkeL | last post by:
Warning: oci_new_connect() : OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in...
6
by: DravenStone | last post by:
Hi, I had just a horrible day at work, spent pretty much the entire day trying to get php_oci.dll and php_oracle.dll to load. It still never did. Super Quick Background. Jack of all trades IT...
4
by: cyrano | last post by:
I am having issues maintaining an oracle connection in my apache/php web application. I am able to succesfully connect to an Oracle 9i dbase using oci() and retrieve expected results for the...
5
by: Mladen Gogala | last post by:
The latest version of OCI8 1.2.1 doesn't work with LOB fields. There was an open bug, but Tony2001 was his usual helpful self, so he removed the bug and flatly denied its existence. I had to...
0
by: Yannick | last post by:
Hi, I'm Julien from France, We have recently install a new Web Server for my company The server is composed : - Linux RedHat RHEL4 U4 - Httpd-2.0.52-27.ent - Oracle Database 10.2.0.1
7
by: eholz1 | last post by:
Hello All, I have reviewed various posts in regard to Oracle and PHP. I am running Apache 2.0.59, on Windows XP, with PHP 5.2. I would like to connect using PHP to a remote oracle db (ver. 7)...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.