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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC