php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7688 loop with in pg_fetch_object
Submitted: 2000-11-08 00:22 UTC Modified: 2000-11-08 15:49 UTC
From: chris dot millsaps at wcom dot com Assigned:
Status: Closed Package: *Function Specific
PHP Version: 4.0.3pl1 OS: Rehat 7.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: chris dot millsaps at wcom dot com
New email:
PHP Version: OS:

 

 [2000-11-08 00:22 UTC] chris dot millsaps at wcom dot com
cannot break out of a while loop using pg_fetch_object. code is as follows: It produces the same row over and over.

function showmessages($parentid)
{ global $dblink;
$Query= "Select id, title, created from message where parent='$parentid'";
if (!(dbresult = pg_exec($dblink, $Query))
{
  print ("couldn't connect!");
  exit(); 
}
while($row = pg_fetch_object($dbResult, $row))
{
print ("<LI>($row->created) <A HREF=\"");
print ("PHP_SELF?id=$row->id\">");
print ("$row->title</A><br>\n");
showmessages($row->id);
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-08 15:49 UTC] mathieu@php.net
object pg_fetch_object (int result, int row [, int result_type])

You have to specify the row to return, user error.

/* Note your typo in (!(dbresult .. and the diff case in variables*/
$numrows = pg_numrows($dbresult);
for ($i=0;$i<=$numrows) {
$row = pg_fetch_object($dbresult, $i);
/* etc */
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC