You are on page 1of 3

STEPS ON HOW TO CONNECT TO ORACLE DATABASE 11g BY USING XAMPP

Prepared by: Muhammad Shakirin Bin Samin


Note: This tutorial has been tested by using XAMPP v3.3.2 and Oracle Database 11g Express Edition

1. Please make sure that youve installed XAMPP with PHP5.2 and above (recommended using
XAMPP with PHP5.5 or PHP5.6). Otherwise, download it at
https://www.apachefriends.org/download.html

2. Open XAMPPs PHP configuration file at C:\xampp\php\php.ini by using Notepad or other


text-editor.

3. Find extension line. | ;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client |
(it might be at line 1008). Then, uncomment the extension by remove the semicolon before
the extension word.

4. Save and close the php.ini configuration file. Now, you may run your XAMPP Control Panel.
Start the Apache service.

5. Open page http://localhost/dashboard/phpinfo.php to check if OCI8 extension is enabled. If


you cant find oci8, try to Stop and Start your Apache. Then, refresh the page.

6. Now, you can create a PHP page to test your Oracle 11g database connection. Below is a
sample of PHP code.
Filename: dbconn.php
<?php

/* php & Oracle DB connection file */


$user = "hr"; //Oracle username
$pass = "system"; //Oracle password
$host = "localhost/XE"; //server name or ip address
$dbconn = oci_connect($user, $pass, $host);
if(!$dbconn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES),
E_USER_ERROR);
} else {
echo "ORACLE DATABASE CONNECTED SUCCESSFULLY!!!"; //you
can remove this
}

?>

7. Run the test page on your browser.

<| The End! |>

You might also like