The code below connects to an Oracle 10g database, but it produces twice the output of every table
Output
T100_S T100_S
T101_S T101_S
T102_S T102_S
although it should be
T100_S
T101_S
T102_S
PHP Code:
<?php
// CONNECT to the database
$conn = oci_connect('stocks', 'stocks');
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
// SELECT and output on the screen
$query = 'SELECT * FROM STOCKS';
$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 '<table border="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);
?>
Output
T100_S T100_S
T101_S T101_S
T102_S T102_S
although it should be
T100_S
T101_S
T102_S
Comment