Connect to remote oracle database from php script

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
asela_05085
Forum Newbie
Posts: 16
Joined: Mon Aug 31, 2009 10:33 pm

Connect to remote oracle database from php script

Post 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
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Connect to remote oracle database from php script

Post by Mark Baker »

You'll need the Oracle client or instant client running on the server that you're trying to connect from
asela_05085
Forum Newbie
Posts: 16
Joined: Mon Aug 31, 2009 10:33 pm

Re: Connect to remote oracle database from php script

Post by asela_05085 »

can you specify such clients :)
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Connect to remote oracle database from php script

Post by Mark Baker »

asela_05085 wrote:can you specify such clients :)
Specify? in what sense?
asela_05085
Forum Newbie
Posts: 16
Joined: Mon Aug 31, 2009 10:33 pm

Re: Connect to remote oracle database from php script

Post 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? :)
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Connect to remote oracle database from php script

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