Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

How to debug inside a while loop

$
0
0

Hey guys,

 

I am trying to grab and loop data from my DB with a while loop and extract() function.

 

right now i have something like this:

 

echo '<div>'; // CONTAINER DIV
echo '<h2>News about '. $db_name. '</h2>';

$query = 'SELECT * FROM `news_to_people` WHERE `people_db_id` = '.$db_id;
$r_query = mysql_query($query);

while($rows=mysql_fetch_assoc($r_query)){
extract($rows);

$new_q = 'SELECT * FROM `news` WHERE `id` = '.$news_id;
$run_q = mysql_query($new_q);

$rows = mysql_fetch_assoc($run_q);
extract($rows);
echo '<ul>';
echo '<l1><a href="article?articleid='.$id.'&name='.$db_name.'">'.$title.'<br></l1>';
echo '</ul>';
}
echo '</div>'; // END TO CONTAINER

Now here i get the loop to fire correctly and execute.

 

It then loops all 170+ links except in the middle of the loop , there is an error:

 

 

Warning: extract() expects parameter 1 to be array, boolean given in/home/justin/public_html/include/demo/center_content.php on line 351

 

 

so this means that i have a failed 2nd query somewhere in that it is skipping inside the while loop.

 

i need to debug and find which query is bringing this error.

 

my question is what is the best way i can write an if statement to see which query is failing or which query is not returning a proper array. also my if the query was failing wouldn't the error be asking for a proper resource ? this means the query is firing correctly and the extract() function is failing to receive all the rows. meaning that one of the rows must be returning empty or zero ? 

 

any help is much appreciated.


Viewing all articles
Browse latest Browse all 13200

Trending Articles