php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4507 Object fetch outputs error when index is greater than # of records
Submitted: 2000-05-18 14:14 UTC Modified: 2000-07-14 23:57 UTC
From: dchapman at houabg dot com Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.0.0 OS: FreeBSD 4.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dchapman at houabg dot com
New email:
PHP Version: OS:

 

 [2000-05-18 14:14 UTC] dchapman at houabg dot com
This code in the manual outputs warning/notification errors when $row is greater than the # of records.  Would a for loop be a better choice?  I've had to turn off warning in the php.ini to get let pages work correctly.

while ($data = pg_fetch_object ($qu, $row)):
 14     echo $data->autor." (";
 15     echo $data->jahr ."): ";
 16     echo $data->titel."<BR>";
 17     $row++;
 18 endwhile; ?>
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-14 23:57 UTC] jah at cvs dot php dot net
Either put @ before pg_fetch_object() to suppress the warning, or use
pg_numrows() first to get the number of rows in the result set. Whether you use
a for or while loop is a personal preference, I doubt there's not much difference
in performance.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 02:01:35 2025 UTC