mysql_fetch_array() is misbehaving - Please help

Started on the old forum in July 2011 · view the original in the archive · old links redirect here

3 replies · 405 views · started 15 years ago · 1 min read

2 participants
s3nzo Developer · 156 posts #1

Hey guys i'm using this code

if(!$row = mysql_fetch_array($catQuery, MYSQL_BOTH))
  $images->showError();
else while($row)
  print $row['category'].'<br>';

and my script is showing only one DB entry and repeat it forever.

i0nutzxp Developer · 150 posts #2

maybe this ....

$i = 0;
while($row = mysql_fetch_object($catQuery))
{ 
     print $row->category.'<br>'; 
     $i++;
}
if  ( ! $i)  $images->showError();
<?php unlink('World/Europe/Romania.country'); ?>
s3nzo Developer · 156 posts #3

Thanks bro, The solution was

while($row = mysql_fetch_array($catQuery, MYSQL_BOTH))

Even though i still don't understand it but yeah it solved my problem

i0nutzxp Developer · 150 posts #4

while(resource) => while the resource exists (infinite loop when you dont delete from resource) while($row = resource) => while the resource is copied to variabile $row while($row == resource) => while resource is equal with row

PS: use MYSQL_ASSOC OR MYSQL_NUM instead MYSQL_BOTH

<?php unlink('World/Europe/Romania.country'); ?>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close