Page 1 of 1

Connecting to Oracle 9i using PHP code

Posted: Mon Jan 17, 2005 12:40 am
by Drayton
Hi to all,

I'm having a little bit of problem connecting to Oracle 9i Database from another server. I'm using Fedora Core 2, PHP Version 4.3.4, Apache2. Ive tried connecting ocilogon function but nothing happens. The result of the code is blank.

Here's the code:

Code: Select all

<?php
$db ="(DESCRIPTION =
     (ADDRESS =
         (PROTOCOL = TCP)
         (HOST = HOSTNAMEHERE)
         (PORT = 1521)
     )
   (CONNECT_DATA = (SID = SIDNAMEHERE))
  )";

$odbc = ocilogon ('user', 'pass', $db) or die( "Could not connect to Oracle database!") or die (ocierror());
?>
running this code with a little bit of configuring the parameters. still nothing happens.
The result still is blank.

Hope someone can help me...
thanks in advance....

Regards
John Drayton C. Fule
Jr. Systems Engineer
Imperium Technology Inc. Phil.


feyd | please use formatting!

Posted: Mon Jan 17, 2005 3:38 am
by onion2k
In all the examples on http://uk2.php.net/ocilogon there appears to be an ADDRESS_LIST directive as part of the $db string.. Not sure if thats relevent though, I've not used Oracle before.

Posted: Mon Jan 17, 2005 4:12 am
by Drayton
Suppose to be would print something on my screen, right? Something like an error message or something but, running the code only gives me a blank screen. I'm aware of that configuration. Thanks anyways! All I want to know is there something i need to do first before i can use oci functions, I've checked out my phpinfo and oci function is enabled. Is it on my php or apache. Just a reminder m trying to connect to the non-local Oracle server .

THANKS!

Posted: Mon Jan 17, 2005 7:37 am
by feyd
well, if the code posted is the entire script, if it succeeded, it wouldn't print anything.. ;)

you can make sure error_reporting() is set to E_ALL, and use ini_set() to set display_errors to on (1).

it also won't print the ocierror() , as the first call to die() will succeed.

Posted: Mon Jan 17, 2005 6:10 pm
by Drayton
It doesn't print anything even if I put the incorrect configuration parameters.

Posted: Mon Jan 17, 2005 6:12 pm
by feyd
did you (re)move the ocierror() call? did you add the following at the start of the file?

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');

Posted: Mon Jan 17, 2005 6:31 pm
by Drayton
I tried to remove the ocierror() and configure my php.ini I got this message.

>>> Fatal error: Call to undefined function: ocilogon()

Posted: Mon Jan 17, 2005 6:49 pm
by feyd
seems you don't have oracle extensions enabled. :?:

Posted: Mon Jan 17, 2005 7:03 pm
by Drayton
According to my phpinfo under DBX >> supported databases >> Oracle >> dbx support enabled. So it means my version of php supports oracle connections, right? What do I need to do to make ocilogon function work on my PHP?

Posted: Mon Jan 17, 2005 7:08 pm
by feyd
seems to say here in the requirements section that you'll need php_oci8.dll running.

Might want to read through the rest of the requirements section too..

Posted: Mon Jan 17, 2005 7:18 pm
by Drayton
Is there a Step by Step procedure on how to make oci functions work on php? or is there any other way to connect on an Oracle DB???:)

Posted: Tue Jan 18, 2005 9:40 am
by hedge
Do you have the Oracle client installed on the web server? That's required. I am not to sure about enabling the extensions on a linux machine, when I connected to oracle I just compiled php with a command line switch pointing to the Oracle install.

Your other option is to use odbc, but I think you'd still need the oracle client installed.

Posted: Tue Jan 18, 2005 6:12 pm
by Drayton
I've already installed the oracle client on my webserver but I have no idea on how to configure the Oracle client on my webserver. Also I've already compiled my php with Oracle extension support. How can I canfigure my oracle client??