473,511 Members | 17,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange problem connecting php to oracle db


A behaviour we don't understand:

+++
$user = 'xxx';
$password = 'xxx';
$database = 'xxx.xxx';

$query = 'SELECT 1 FROM DUAL';
$link = OCIlogon($user, $password, $database);

//$parse = OCIParse($link, $query);
unset($link);

$link = OCIlogon($user, $password, $database);
$parse = OCIParse($link, $query);
+++
-> "... is not a valid oci8 connection resource"

Everything works fine if the first line with $parse is not
commented out. Everything also works fine if we do not
unset $link.

This behaviour occurs with ocilogon(), not with
either ociplogon() or ocinlogon().

Tested with PHP 4.3.11 on Linux, Apache 1.3.33 and Apache
1.3.34, OCI PECL extension 1.1.1, Oracle 10.2.01 and
10.1.0.3.

Best regards
Keith
Feb 20 '06 #1
3 1808
On Mon, 20 Feb 2006 13:16:46 +0100, Keith E. Sauvant wrote:

A behaviour we don't understand:
Who is "we"?

+++
$user = 'xxx';
$password = 'xxx';
$database = 'xxx.xxx';

$query = 'SELECT 1 FROM DUAL';
$link = OCIlogon($user, $password, $database);

//$parse = OCIParse($link, $query);
unset($link);
Why would do that? Unset will call the destructor and will
log you out of the database? Are you trying to log in for
each SQL statement?

$link = OCIlogon($user, $password, $database);
$parse = OCIParse($link, $query);
+++
-> "... is not a valid oci8 connection resource"

Everything works fine if the first line with $parse is not
commented out. Everything also works fine if we do not
unset $link.

This behaviour occurs with ocilogon(), not with
either ociplogon() or ocinlogon().

Tested with PHP 4.3.11 on Linux, Apache 1.3.33 and Apache
1.3.34, OCI PECL extension 1.1.1, Oracle 10.2.01 and
10.1.0.3.

Best regards
Keith

I would have written that like this:

$link = OCIlogon($user, $password, $database);
if (!$link) {
$err=oci_error();
die("General Protection Fault:$err<br>\n");
}
$handle1 = OCIParse($link, $query1);
$handle2 = OCIParse($link, $query2);

/* Note that checking for errors makes no sense as oracle
does error checking only when it attempts to execute
the cursor. */

oci_execute($handle1);
$err=oci_error($link);
if ($err) die("General Protection Fault:$err<br>\n");

oci_execute($handle2);
$err=oci_error($link);
if ($err) die("General Protection Fault:$err<br>\n");

Note that error checking is necessary after each statement as neither OCI8
nor PHP4 support exceptions. I wholeheartedly recommend switching to PHP5
as it is stable enough for production and makes the life of poor
programmer much, much easier.
--
http://www.mgogala.com

Feb 20 '06 #2
>> A behaviour we don't understand:
Who is "we"?
That is me and my colleagues ;-)
Why would do that? Unset will call the destructor and will
log you out of the database? Are you trying to log in for
each SQL statement?
I do not want to do that. That where just some lines of code to
reproduce my problem.
I would have written that like this: ...


You are absolutely right. But besides that: Can you explain what happens
in my example?

Best regards
Keith
Feb 20 '06 #3
On Mon, 20 Feb 2006 21:55:39 +0100, Keith E. Sauvant wrote:
You are absolutely right. But besides that: Can you explain what happens
in my example?


You have destructor mess up something and the new connect is not
able to go through. It would be much easier to debug you code
snippet if there was an entry from the error_log file or oci_error
result. This is just guesswork, but that is all that I can tell,
based on what you gave me.

--
http://www.mgogala.com

Feb 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5602
by: Demetris | last post by:
Hello there. I have ORACLE 8.1.7.4 server on AIX 5.1. I have another server (BIZTALK) with Oracle client 8.1.7. The system is running ok. I can connect from the client on my database server just...
1
3174
by: Wayne Happ | last post by:
I have Oracle 9 running on a Linux RedHat Box V9.0. But I'm having trouble connecting from a windows machine via PL/SQL Develover. When I startup the application the instance name appears but...
0
1386
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong...
2
1640
by: msnesw.microsoft.com | last post by:
I developed a web application about a year ago that connects to the Oracle DB using MS ODBC for Oracle. But I had to move the whole application to a brand-new PC . When I try to run I get the...
2
3658
by: Mahesh.V | last post by:
Hi All I get the following error while connecting to the oracle database using ODBC. in my VB.NET application. Can any one help me out solving this problem server message (if any):...
2
3434
by: python_eager | last post by:
Hi i am connecting my database oracle 9i. While connecting i am getting the following error connection = cx_Oracle.connect("myusername", "mypassword", "python") RuntimeError: Unable to acquire...
2
5519
by: rcc.gamer | last post by:
Hello All, I am trying to connect a GridView to an Oracle table using the standard SqlDataSource. The process is fairly simple and there are detailed instructions from Microsoft ......
0
3139
by: Temporary | last post by:
C# Web Service in IIS Stops Connecting to Oracle (via ADO.NET) Over Time I have a Web Service, written in C#, published on a Windows XT Web Server under IIS, which repeatedly connects to an...
17
5911
by: kanishka1213 | last post by:
when i run perl script in the cmd prompt , it runs well and outputs results from db. but when i run the same script on apache server internet explorer. i get an error as -----...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.