Jump to content

mysql error in php script


wolfas

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  ;)
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.