Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to connect to a remote oracle database using php

Posted on 2001-08-19
10
329 Views
Last Modified: 2010-08-05
How do i connect to a remote oracle using php? I'm running php 4.0.6/apache on red hat linux. What do i need to install in order to access the remote oracle database?
0
Comment
Question by:juan_tanga
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 4

Accepted Solution

by:
gizmola earned 50 total points
ID: 6405010
You need to install the Oracle client libraries. There is no seperate client CD, you need the Oracle for Linux CD or installation software in order to do the client install. Then use the oracle functions described here to connect:

http://www.php.net/manual/en/ref.oracle.php

0
 

Author Comment

by:juan_tanga
ID: 6405022
Can i download the Oracle client libraries on their website?
0
 

Author Comment

by:juan_tanga
ID: 6405045
Can i download the Oracle client libraries on their website?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

by:TRXR
ID: 6405541
i think you just have to include the php_oci8.dll and/or the php_oracle.dll in the php.ini depending on the interface you want to use (you can use two sets of functions to access the db: ora_xxx and oci_xxx). the dlls are in your php/extensions directory. you also have to fill in the correct extensions path at extension_dir = "", so the php.exe may find these dlls.
this version of php does support oracle, you just have to switch it on.

good luck.
0
 

Expert Comment

by:TRXR
ID: 6405660
sorry
just recognized u r using linux
actualy it should be something simmilar

good luck again
0
 
LVL 4

Expert Comment

by:gizmola
ID: 6406650
No you can't. Oracle doesn't provide the client libraries for download. You need to get a copy of Oracle for Linux.  one of the trial versions that they have available for download may do the job.
0
 

Author Comment

by:juan_tanga
ID: 6416123
i downloaded the oracle8i enterprise for linux. Is it compatible to Oracle 8 (not i) enterprise edition? co'z thats our serving running on windows nt
0
 
LVL 4

Expert Comment

by:gizmola
ID: 6416479
Yes the client libraries should be backwards compatible.
0
 
LVL 4

Expert Comment

by:kalosi
ID: 6421209
You have to install a oracle client. Versions 8.1.6 or 8.1.7 for linux will fit your needs. As you wrote that you use linux I assume that you use apache/php combonation. To get the whole thin working you will have to export the oracle variables
Simply put theese line to your /etc/profile


ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/OraHome1
ORA_NLS33=/opt/oracle/OraHome1/ocommon/nls/admin/data
ORACLE_OWNER=oracle
NLS_LANG=AMERICAN_AMERICA.EE8ISO8859P2
TNS_ADMIN=/opt/oracle/OraHome1/network/admin

of course replace the paths to fit your installation. don't forget to export the variables. The next thing is you have to
set up your tnsnames.ora and sqlnet.ora located in TNS_ADMIN directory

here is a sample sqlnet.ora file

names.default_domain = WORLD
name.default_zone = WORLD
names.directory_path = (TNSNAMES, HOSTNAME)

and here is a sample tnsnames.ora entry

ORACLE_SID.WORLD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (COMMUNITY = tcp.world)(PROTOCOL = TCP)(Host = 12.2.33.12)(Port = 1521))
      (ADDRESS = (COMMUNITY = tcp.world)(PROTOCOL = TCP)(Host = 12.2.33.12)(Port = 1526))
    )
    (CONNECT_DATA = (SID = ORACLE_SID)(SERVER=DEDICATED))
   )



to test it try first the tnsping utility tnsping oracle_sid if it returns OK try sqlplus username/password@oracle_sid to log on to database. if you succeed yout oracle instalation works correctly.

And one common pitfall: you might get some trouble when starting the apache instance with apachectl script it does not read the enviroment variables. try to start it with the original httpd script. Another solution is to put the variables from /etc/profile to the starting script and also to the apache owners .bash_profile.

To make sure that everything is in place try to write a sample php script

<?

echo getenv("ORACLE_HOME");
echo getenv("TNS_ADMIN");
echo getenv("NLS_LANG");

?>


that's all hope it helps
0
 

Author Comment

by:juan_tanga
ID: 6427601
thanks but I guess i don't need it anymore co'z i already connected using the username@host format in ora_logon()command in php.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question