Dear all,
I have a problem about Oracle9 run on Linux/PHP.
I can successful connect to Oracle DB.
but have a big problem.
I didn't know why page not found when finished OCIExecute? and If I remark all below "select from test_table" code, it can show count() sql statment result. What error?? is it miss something?? Pls help.....
here is my code:
<?php
$db = " (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = oracle.myhome.com))
)";
$conn = OCILogon("oracle", "oracle", $db);
if (!$conn) {
echo "ERROR - Could not connect to Oracle";
exit;
}
$sql = "Select count(*) from test_table";
$stmt = OCIParse($conn, $sql);
if(!$stmt) {
echo "parse SQL err".$sql;
exit;
}
OCIExecute($stmt);
OCIFetchInto($stmt, &$total_rows);
if ( !$total_rows[0] ) {
echo "Error - no rows returned!";
exit;
}
echo "There are <b>$total_rows[0]</b> results.<br>\n";
$sql = "select * from test_table";
$stmt = OCIParse($conn, $sql);
if(!$stmt)
{
echo "parse SQL err - ".$sql;
}
OCIExecute($stmt);
$nrows = OCIFetchStatement($stmt,$results);
if ( $nrows > 0 ) {
echo "<TABLE BORDER=\"1\">\n";
echo "<TR>\n";
while ( list( $key, $val ) = each( $results ) ) {
echo "<TH>$key</TH>\n";
}
print "</TR>\n";
for ( $i = 0; $i < $nrows; $i++ ) {
reset($results);
echo "<TR>\n";
while ( $column = each($results) ) {
$data = $column['value'];
echo "<TD>$data[$i]</TD>\n";
}
echo "</TR>\n";
}
echo "</TABLE>\n";
} else {
echo "No data found<BR>\n";
}
print "$nrows Records Selected<BR>\n";
OCIFreeStatement($stmt);
OCILogoff($conn);
?>