PDA

View Full Version : Connect with remote oracle database from PHP


asela_05085
Sep 3, 2009, 05:51 AM
Hi,

I need to connect to a remote oracle database from a PHP script.
Do I need to install any drivers or packages to connect with the remote database?

When I use below code

<?php
if ($c = oci_connect("username", "passwd", "remote server IP")) {
echo "Successfully connected to Oracle.";
oci_close($c);
} else {
$err = oci_error();
echo "Oracle Connect Error " . $err['text'];
}
?>

It gives below error
"PHP Fatal error: Call to undefined function: oci_connect() "

I'm wondering whether I need to install any drivers

Advice someone

Thanks
Edit/Delete Message

retsoksirhc
Sep 3, 2009, 06:22 AM
What type of server are you using? You need to enable support for oracle in php, either by compiling it with support or installing relevant packages on linux, or uncommenting the line to include the extension dll in windows.

retsoksirhc
Sep 3, 2009, 06:24 AM
This link may help, too
PHP: OCI8 - Manual (http://us2.php.net/manual/en/book.oci8.php)

I'm not really familiar with Oracle, but I do know my way around PHP pretty well.

asela_05085
Sep 3, 2009, 06:30 AM
I'm running my WEB Service on redhat linux machine with PHP 4.3 and I need to connect with a remote oracle db.
Can you let me know what are those packages.
I have searhed but couldn't found anything

Thanks

retsoksirhc
Sep 3, 2009, 07:09 AM
I'd start with this to install the oracle libraries on your linux box. It'd probably be easiest to just download and run the RPM
Instant Client downloads for Linux x86 (http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html)

Then I would find your PHP ./configure (where you had installed PHP from) and run it again, with --with-oci8, along with all your other options. One of the examples here: PHP: Installation - Manual (http://us2.php.net/manual/en/oci8.installation.php) says to do this

/configure --with-oci8=instantclient,/usr/lib/oracle/10.2.0.2/client

There should be one option on that pages that works for you.

asela_05085
Sep 3, 2009, 08:13 PM
Thanks retsoksirhc.
I'll try that