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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 09:01:27 2019 UTC