Jump to content


Photo

mysql error in php script


  • Please log in to reply
1 reply to this topic

#1 wolfas

wolfas
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 September 2006 - 02:50 PM

Hi,
when i use only "while{}" my script works but when i add a "for{}" in "while{}" i get a following error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/index.php on line 57
here is the code :
while ($row = mysql_fetch_array($r))//line 57
  {
    echo "$row[ivykis] $row[form]";
    if ($row['form']==1) {$f++;    echo "Taip <input type=\"radio\" name=\"radio$f\" value=\"taip\"> Ne <input type=\"radio\" name=\"radio$f\" value=\"ne\"><br>";}
    if ($row['form']==2) {$insk++; echo " <input type=\"text\" name=\"text$insk\" maxlength=3 size=4><br>";}//inputas
    if ($row['form']==3)
      {
          $sesk++;
        echo "<select name=\"selectas$sesk\">"; 
        for ($r=0;$r<=$ssk;$r++)
          {     
              echo "<option value=\"$zzz[$s]\">$zzz[$s]</option>";
          }
          echo "</select>";
      }

thanks in advance  ;)

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 September 2006 - 02:54 PM

Its beacuse your are overwritting the result resource in your for loop. $r is the result resource from the SQL Query you have just run. You are assign $r to zeror in the for loop. change $r if your for loop to something else, like $_r that way it wont overwrite the result resource.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users