tags:

views:

203

answers:

2

The PHP function oci_connect (which connects to an Oracle database) just returns false if it fails, which at the moment I handle like this:

$connection = oci_connect($username, $password, $database);
if (!$connection){
 return $result = "Trouble connecting to the Oracle Database";
}

But really I'd like to have the actual ORA error code, so I can be more informative. Is this possible?

A: 

Have you tried examining the results of oci_error()?

I haven't used Oracle with PHP (sadly) but the MySQL the general pattern is:

if (!mysql_connect(...)) {
  error_log('Error connecting: ' . mysql_error()); // or just die
}

It seems logical that the Oracle pattern would be:

if (!oci_connect(...)) {
  error_log('Error connecting: ' . oci_error());
}
cletus
Thanks cletus! Works great
me_here
A: 

I am using CestOs as the server. Database used is oracle 10g R2. and php used is php 4.1.2.

When I build php and browse the application it words but if the server is restart, php connection string doesnot works. It display nothing. I have database, apache and php installed in same machine. So, no instant client is used. I guess it is not connection string problem.

Please help me.

Pramod Poudel