Page 1 of 1

Connect to remote oracle database from php script

Posted: Thu Sep 03, 2009 5:56 am
by asela_05085
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

pls advice someone

thanks

Re: Connect to remote oracle database from php script

Posted: Thu Sep 03, 2009 5:59 am
by Mark Baker
You'll need the Oracle client or instant client running on the server that you're trying to connect from

Re: Connect to remote oracle database from php script

Posted: Thu Sep 03, 2009 6:04 am
by asela_05085
can you specify such clients :)

Re: Connect to remote oracle database from php script

Posted: Thu Sep 03, 2009 6:07 am
by Mark Baker
asela_05085 wrote:can you specify such clients :)
Specify? in what sense?

Re: Connect to remote oracle database from php script

Posted: Thu Sep 03, 2009 6:24 am
by asela_05085
since I'm totally new i don't know much about this
do you mean to install a client in the server(my server is a linux machine with PHP 4.3)
if so what are those client that serve my need? :)

Re: Connect to remote oracle database from php script

Posted: Thu Sep 03, 2009 7:09 am
by Mark Baker
asela_05085 wrote:since I'm totally new i don't know much about this
do you mean to install a client in the server(my server is a linux machine with PHP 4.3)
if so what are those client that serve my need? :)
You would need to install either the Oracle Client or the Oracle Instant Client for Linux. If your Oracle database is instaklled on a Linux database, then this should be available on the CD that the database server was installed from. If not, or if your database server is running 64-bit Linux and your web server is 32-bit Linux, then you'll need to locate a copy of the appropriate version of Oracle, as a download from metalink or from your database support team.

I'd also recommend upgrading the version of PHP that you're running as well. 4.3 is very old now