9.编辑php代码连接测试Oracle数据库
- <?php
- $conn = oci_connect('scott', 'oracle', '192.168.12.133/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 '<tableborder="1">';
- while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
- print '<tr>';
- foreach($row as $item) {
- print '<td>'.($item?htmlentities($item):' ').'</td>';
- }
- print '</tr>';
- }
- print '</table>';
- oci_close($conn);
- ?>
最后通过浏览器浏览页面

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
