473,669 Members | 2,386 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 1813
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($ha ndle1);
$err=oci_error( $link);
if ($err) die("General Protection Fault:$err<br>\ n");

oci_execute($ha ndle2);
$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
5608
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 fine. However at certain stages we get the error below when it tries to open a connection.Please note that we are loading 150,000 records currently and we open / close a connection for every call. ORA-12154: TNS:could not resolve service name
1
3184
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 when I try to login as sysdba I get the error. ORA-12545 Connection failed because target host or object does not exist. I'm guessing that there's something net8 I have to setup. This is a new installation. Can someone point me in the right...
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 Li (likong@email.com)
2
1646
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 error: "The Oracle(tm) client and networking components were not found. These components are supplied by Oracle Corporation..." I installed the Oracle client (v8i) and MDAC_TYP.EXE for any ODBC components. Then I added Microsoft.Data.Odbc as a...
2
3666
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): "ORA-12154:TNS:could not resolve service name Thank in Advance Mahesh.V
2
3456
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 Oracle environment handle please send the solution
2
5529
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 ... http://msdn2.microsoft.com/en-us/library/ms178304(vs.80).aspx The problem is not accessing or displaying data from an Oracle table .... that all works great!
0
3145
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 Oracle 9x database via ADO, processes, disconnects from the database, and exits. The Web Service is triggered by our Tibco messaging system; in our test environment, it is
17
5940
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 ----- install_driver(Oracle) failed: Can't load 'C:/perl/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified module could not be found at C:/perl/lib/DynaLoader.pm line 202. at (eval 5) line 3 Compilation failed in require at (eval 5) line 3....
0
8465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8809
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.