[CS-FSLUG] Why one but not the other (SQL query)

Frank Bax fbax at sympatico.ca
Sat Dec 27 13:05:24 CST 2008


David McGlone wrote:
> $query = "SELECT * FROM subheaderText";
> $result= mysql_query($query);
> $num = mysql_fetch_array($result);
> $num=0;
> while ($num < $result){
> echo "$subheaderTextID<br>"; 
> $num++;
> echo $num;
> }
> this query echo's back: 12345.
> 
> In the above code, I believe that $result should contain all 6 rows


$result does not contain all 6 rows; $result is a "resource"; an object 
you can send to other mysql functions (like mysql_fetch_array); but it 
has no meaning within php itself.

If you insert/remove a call to any mysql function before the above code; 
you will get different results from this loop.






More information about the Christiansource mailing list