Connecting to Oracle 9i using PHP code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Connecting to Oracle 9i using PHP code

Post 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!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Post by Drayton »

It doesn't print anything even if I put the incorrect configuration parameters.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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');
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Post by Drayton »

I tried to remove the ocierror() and configure my php.ini I got this message.

>>> Fatal error: Call to undefined function: ocilogon()
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

seems you don't have oracle extensions enabled. :?:
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Post 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???:)
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post 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.
User avatar
Drayton
Forum Newbie
Posts: 24
Joined: Thu Apr 01, 2004 2:14 am

Post 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??
Post Reply