Re: Infinite Loop Issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 6, 2008 at 11:59 PM, Jim Lucas <lists@xxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux