Page 1 of 1

connect to a remote Oracle DB

Posted: Fri Oct 20, 2006 7:31 am
by yarons
Hello,
I'm trying to connect to a remote Oracle server. I'm using PHP 5.1.6 and APACHE 2.2.3.
I have all the Oracle details I need, I have the server host, server name, user/pass and port.

How can I connect to it and start firing off queries?
I looked in some of the existing function (ora_logon,OCILogon, oci_connect) but it appears that none of them is accepting my connection details as parameters.

Thanks.

Posted: Fri Oct 20, 2006 1:17 pm
by feyd
The first note on oci_connect()'s page would suggest some form of DSN. On the older oracle pages, remote connections were added to some configuration file.

Posted: Fri Oct 20, 2006 1:25 pm
by RobertGonzalez
Does it require a server side client to connect? Does it require drivers?

Posted: Wed Dec 13, 2006 5:36 pm
by emmbec
Does anyone have an example on the connection string to a remote ORACLE database?? I've been trying to look for one, and an easy to follow tutorial but I just can't seem to find one. If anyone knows, could you please post it here? This are my DB details....

HOST: my.servername.com
PORT: 1234
SID: engr

Thanks!

Posted: Wed Dec 13, 2006 6:48 pm
by RobertGonzalez
http://www.connectionstrings.com/

There is an Oracle section in their. You might also want to search Oracle's web site as they are continually adding information about Oracle and PHP.

Posted: Mon Dec 18, 2006 11:54 am
by emmbec
OK, after doing a lot of research I found that I had to do the following:

I had to uncomment the OCI8 extension in PHP.INI:

Code: Select all

extension=php_oci8.dll

I download the Instant Client Basic package for Windows from the Oracle site.

I created a subdirectory (e.g., c:\instantclient10_2) and copy these libraries from the zip file:
  • * oraociei10.dll
    * orannzsbb10.dll
    * oci.dll
I have edited the environment and add c:\instantclient10_2 to PATH before any other Oracle directories.

This is a sample from my PHP.INI file(I am using XAMPP so the location for this file is: C:\xampp\xampp\apache\bin I had a lot of problems editing the wrong PHP.INI file :wink:) for the extension path:

Code: Select all

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\xampp\xampp\php\ext\"
Make sure it is correct and corresponds to where you have PHP installed.

NOTE: I am using XAMPP 1.5.5 and Windows 2000, there are instructions on the Oracle website to configure php and oracle on Linux.

I did all of that (which was in the oracle site http://www.oracle.com/technology/pub/no ... stant.html) and if you run PHPINFO() there HAS TO BE an OCI8 Section in that page if it is not, then you did something wrong.

Now here is an example of the connection string to oracle:

Code: Select all

$conn = OCILogon("USER_NAME", "PASSWORD","//oracle_server.domain:1521/DB_NAME");
Now the OCILogon instruction gets recognized, but I have just one more problem, my Oracle database is in another server, and when I run the above code I get the following warning:
Warning: ocilogon() [function.ocilogon]: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in C:\xampp\xampp\htdocs\test\test.php on line 2
Does anyone knows how to fix this???