Installed Oracle 10g Express on Scientific Linux 6.2 before
http://wowmoron.blogspot.in/2012/12/install-oracle-10g-express-on.html
Ok installed PHP and Apache on Scientific Linux 6.2 before
http://wowmoron.blogspot.in/2012/11/install-apachemysqlphp-lamp-on-centos.html
Now connecting Oracle 10g express using PHP
all we have to do basically installing zend server community edition
so the steps are
create a file
/etc/yum.repos.d/zend.repo
[Zend]
name=zend-server
baseurl=http://repos.zend.com/zend-server/6.0/rpm/$basearch
enabled=1
gpgcheck=1
gpgkey=http://repos.zend.com/zend.key
[Zend_noarch]
name=zend-server - noarch
baseurl=http://repos.zend.com/zend-server/6.0/rpm/noarch
enabled=1
gpgcheck=1
gpgkey=http://repos.zend.com/zend.key
save the file and close
yum install zend-server-php-5.3
after this
nano /var/www/html/database.php
<?php
$conn = oci_connect("hr", "your_hr_password", "127.0.0.1/XE");
$stid = oci_parse($conn, "select last_name, salary from employees");
oci_execute($stid);
$nrows = oci_fetch_all($stid, $results);
echo "<html><head><title>Oracle PHP Test</title></head><body>";
echo "<center><h2>Oracle PHP Test</h2><br>";
echo "<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
echo "<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";
for ($i = 0; $i < $nrows; $i++ ) {
echo "<tr>\n";
echo "<td>" . $results["LAST_NAME"][$i] . "</td>";
echo "<td>$" . number_format($results["SALARY"][$i], 2). "</td>";
echo "</tr>\n";
}
echo "<tr><td colspan='2'> Number of Rows: $nrows</td></tr></table>";
echo "<br><em>If you see data, then it works!</em><br></center></body></html>\n";
?>
(ok as I can not use opening tag and closing tag in this blog I used > and < instead)
save the file and close
open your browser
localhost/database.php
you should see data and you are done
No comments:
Post a Comment