R7AF
asked on
No results for php/postgresql query
When I execute the following code, I get a blank page. However, if I remove the complete for-loop, and only display the number of rows (pg_num_rows($result)), I do get the correct value back. I don't see what I'm doing wrong here.
System: Windows Vista, PG8.3, PHP 5.2.9
System: Windows Vista, PG8.3, PHP 5.2.9
<?php
$query = "select name from person;";
$result = pg_query($db, $query);
if ($result)
{
$rows = pg_num_rows($result);
echo("result: ". $rows);
// start problem code
for ($row = 0; $row < $rows; $row++)
{
$values = pg_fetch_row($result, $row);
echo 'Person: ' . implode(' ', $values) . " <br/>\n";
}
else
{
echo ("Query error: " . pg_last_error($db) );
}
// end problem code
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER