Jump to content

Archived

This topic is now archived and is closed to further replies.

wolfas

mysql error in php script

Recommended Posts

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  ;)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.