Announcement

Collapse
No announcement yet.

whats wrong with this code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • whats wrong with this code

    i get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/equaked/public_html/reviews/new/index.php on line 98

    when running this code:
    PHP Code:
    while($stuff mysql_fetch_array("SELECT website,sitename FROM sites WHERE status='0'")){ 
    any ideas whats wrong with it?

  • #2
    The "proper" syntax would be:
    PHP Code:
    while($stuff mysql_fetch_array(mysql_query('SELECT website,sitename FROM sites WHERE status=0'))){ 
    But that won't work, since the condition in while() is evaluated every time the loop is iterated, so you will always get the first record in $stuff and the loop will run infinitely.

    The right way to do this:
    PHP Code:
    $stuffs mysql_query('SELECT website,sitename FROM sites WHERE status=0');
    while(
    $stuff mysql_fetch_array($stuffs)){ 
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

    Comment


    • #3
      works, thanks for the help firefly.. now if php didnt have to be so picky ;/.

      Comment

      Related Topics

      Collapse

      Working...
      X