Home arrow Oracle arrow Page 2 - Installing Oracle Database XE on the Windows Platform

Configuring Oracle and PHP - Oracle

In this second part of a five-part article series on installing Oracle Database XE, you'll learn how to install the database on the Windows platform, and enable PHP to connect to the database. This article is excerpted from chapter 27 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).

TABLE OF CONTENTS:
  1. Installing Oracle Database XE on the Windows Platform
  2. Configuring Oracle and PHP
By: Apress Publishing
Rating: starstarstarstarstar / 2
November 04, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Now that we have all of the required components for our Apache/PHP/Oracle on Windows environment installed, you must perform the final hookup: enabling PHP to connect to the Oracle database. 

Find the PHP configuration filephp.iniyou created in Chapter 2 and locate this line in the file:

;extension=php_oci8.dll

Remove the semicolon at the beginning of the line and save the file in its original location. Be sure to check the value of the parameterextension_dirinphp.ini; its value is the directory where PHP finds its extensions. For this particular PHP installation, here is the value ofextension_dir:

extension_dir = "c:\php5.2.0\ext"

If the filephp_oci8.dllis not in the directory referenced by the parameterextension_dir(along with about 45 other extensions), locate it and change the value of this parameter to the directory containing it. For these changes to take effect, you must restart the Apache HTTP server. The easiest way to do this in Windows is to use the Start menu. Click All Programs ? Apache HTTP Server ? Control Apache Server ? Restart. Unless an error occurs, you will briefly see a command window. To see if PHP can connect to Oracle successfully, create the filetest_ora_conn.phpusing the code in Listing 27-1 and place it in your Apache document root. For a default Apache 2.2 installation on Windows, the document root directory isC:\Program Files\Apache Software Foundation\Apache2.2\ htdocs. If you followed the Apache installation instructions in Chapter 2, the document root directory isC:\Apache2\htdocs.

Listing 27-1. PHP Code to Test Oracle Connectivity (test_ora_conn.php)

<?php
if ($conn = oci_connect('system', 'yourpassword', '//localhost/xe')) {
   
print 'Successfully connected to Oracle Database XE!';
   
oci_close($conn);
} else {
   
$errmsg = oci_error();
   
print 'Oracle connect error: ' . $errmsg['message'];
}
?>

Be sure to substitute the password you entered in the step shown in Figure 27-4 in the second line of the script; otherwise you will exercise theelseclause of theifstatement in the PHP code. Navigate to this URLhttp://localhost/test_ora_conn.php, and you should see the success message in the firstprintstatement.

Youíve probably seen the Oracle-specific function calls such asoci_connectandoci_errorin examples earlier in this book. Weíll talk about them more formally in Chapter 28 and throughout the examples in the rest of the book.

Please check back next week for the continuation of this article.



 
 
>>> More Oracle Articles          >>> More By Apress Publishing
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ORACLE ARTICLES

- Oracle Java Security Woes Continue
- Oracle's New IaaS Cloud Option: There's a Ca...
- Oracle Acquires Eloqua to Boost Cloud Presen...
- Choosing Innovation: Oracle Survey Insights
- Oracle Fixes Privilege Escalation Bug
- Oracle`s Communications Service Availability...
- Oracle Releases Exalytics, Taleo Plans
- Oracle Releases Communications Network Integ...
- Oracle Releases Communications Data Model 11...
- Oracle Releases PeopleSoft PeopleTools 8.52
- Oracle Integrates Cloudera Apache Distro, My...
- Oracle Releases MySQL 5.5.18
- Oracle Announces NoSQL Database Availability
- Sorting Database Columns With the SELECT Sta...
- Retrieving Table Data with the LIKE Operator

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: