Flicker Images

Find programmers and grapic design experts at ScriptLance.com

Monday, April 18, 2011

Setting up an Oracle / PHP connection



Require Software:
Oracle 10g Express edition:

PHP
Apache

Or

Wampserver

Or

XAMAP



This time I am using Wampserver 2i.  For avoiding hassle installing apache and PHP install separately.
You can install apache and PHP separately.

Now describe step by step:

Step 1: Install wampserver .
Step 2: Install Oracle 10g express edition.
Step 3:
The OCI8 and PDO_OCI extensions are included in PHP.
The basic steps to configure OCI8 are:

  •    Open  your php.ini file
  •    Search OCI8 in php.ini file

  •         Default it’s commented so you need to uncomment it.


Step 4:  Now check your oracle client. 
Step 5:  create a sample php file “test.php”
<?php

echo "hello world";

$conn = oci_connect('myusername', 'password', 'host/xe');

do_query($conn, 'SELECT * FROM TAB1);
// Execute query and display results
function do_query($conn, $query)
{
$stid = oci_parse($conn, $query);
$r = oci_execute($stid, OCI_DEFAULT);
print '<table border="1">';
while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
print '<tr>';
foreach ($row as $item) {


 echo "  <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;")."</td>\n";
}
print '</tr>';
}
print '</table>';
}

?>

Step 6: Now run you server and open that “test.php”
Share:

Game Reviews

BTemplates.com

Powered by Blogger.

Search This Blog

Video Of Day

Find Us OIn Facebook

Blogroll

Contact

Tackle the Web with up to 5 new .COMs, $5.99 for the 1st year!

Advertisement