473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 12562
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.