Re: Infinite Loop Issue

From: Date: Fri, 07 Nov 2008 13:11:52 +0000
Subject: Re: Infinite Loop Issue
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-283066@lists.php.net to get a copy of this message
On Thu, Nov 6, 2008 at 11:59 PM, Jim Lucas <lists@cmsws.com> wrote: > Kyle Terry wrote: >> I believe I'm doing everything right here. It just seems like it doesn't >> end. The browser just keeps trying to load the page forever... >> >> function displayAll(){ >> global $db; > > What the heck is in $db? Which SQL class(es) are you using for your DB handler? [snip] I believe the OP already said it's (supposed to be) an instance of mysqli, and in that sense the code looks very similar to the example in the manual for mysqli_stmt::fetch(). One difference I see that may help track down the problem is that the example checks to see whether the mysqli::prepare() statement actually returns a result. <?php function displayAll(){ global $db; $sql = "SELECT release_id, description, date(release_date) AS date, issues, priority FROM release_data"; // INSERT IF TEST HERE... if ($all = $db->prepare($sql)) { $all->execute(); $all->bind_result($release_id, $description, $date, $issues, $priority); while($all->fetch()){ $i = 0; $iss_link = explode(', ', $issues); // INITIALIZE $row2 $row2 = array(); foreach($iss_link as $a){ $row2[$i] = "<a href=\"http://mantisus/view.php?id=$a\"target=\"_blank\">".$a.'</a>'; $i++; } $issues = implode(', ', $row2); echo $release_id; echo $description; echo $date; echo $issues; echo $priority; echo '<br />'; } $all->close(); // ADD AN ELSE IN CASE THERE IS AN ERROR MESSAGE } else { echo $db->error(); } } ?> Andrew

« previous php.general (#283066) next »