Php connection to access Oracle is using the oci function, the following is the finishing documentation 1. install Apache and php package yuminstall-yhttpdphp * 2. download the Oracle component oracle-instantclient-basic-10.2.0.4-1.i386.rpmoracle-instantclient-sqlplus-10.
The oci function is used to connect to Oracle using php. the following documents are provided:
1. install Apache and php packages
Yum install-y httpd php *
2. Download Oracle components
Oracle-instantclient-basic-10.2.0.4-1.i386.rpm
Oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
Oracle-instantclient-devel-10.2.0.4-1.i386.rpm
Oracle-instantclient-odbc-10.2.0.4-1.i386.rpm
# Rpm-ivh oracle-instantclient * (all four components are installed)
The/usr/lib/oracle/10.2.0.4/client/lib/directory is generated.
3. modify the/etc/ld. so. conf file.
# Vim/etc/ld. so. conf
Append the following content
/Usr/lib/oracle/10.2.0.4/client/lib/
# Ldconfig (Execute command)
4. download the OCI8 component
# Tar zxvf oci8-1.4.1.tgz
5. edit the OCI8 module
# Cd oci8-1.4.1
# Phpize (Execute command)
#./Configure -- with-oci8 = instantclient,/usr/lib/oracle/10.2.0.4/client/lib/
# Make install
The system will prompt you that oci8.so has been successfully put into the/usr/lib/php/modules/directory.
6. modify the php. ini file
# Vim/etc/php. ini
Append the following content
Extension = oci8.so
7. restart the Apache service
Service httpd restart
8. use the phpinfo () function to view
9. edit the php code to connect and test the oracle database
$ Conn = oci_connect ('Scott ', 'Oracle', '192. 168.12.20./ orcl ');
If (! $ Conn ){
$ E = oci_error ();
Print htmlentities ($ e ['message']);
Exit;
}
$ Query = 'SELECT ename, sal from scott. emp ';
$ Stid = oci_parse ($ conn, $ query );
If (! $ Stid ){
$ E = oci_error ($ conn );
Print htmlentities ($ e ['message']);
Exit;
}
$ R = oci_execute ($ stid, OCI_DEFAULT );
If (! $ R ){
$ E = oci_error ($ stid );
Echo htmlentities ($ e ['message']);
Exit;
}
Print'
'; While ($ row = oci_fetch_array ($ stid, OCI_RETURN_NULLS )){ Print'
'; Foreach ($ row as $ item ){ Print'
'. ($ Item? Htmlentities ($ item ):'').' | '; } Print'
'; } Print'
';
Oci_close ($ conn );
?>
Finally, browse the page through a browser
This article is from the blog "no matter how many miles you have done". I am not allowed to repost it!