Jump to content

Can anyone see the problem :\


illuz1on

Recommended Posts

hey whats wrong here? getting this error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/capetown/public_html/feature-edit.php on line 134

 

 

Cant figure it out!

 

code of edit-feature.php::

 

<? 
//connect to mysql

require_once("db.php");

//If cmd has not been initialized
if(!isset($cmd)) 
{
   //display all the news
   $result = mysql_query("select * from featured"); 
   
   //run the while loop that grabs all the news scripts
   while($r=mysql_fetch_array($result)) 
   { 
      //grab the title and the ID of the news
      $ft=$r["ft"];//take out the title
      $id=$r["id"];//take out the id
     
 //make the title a link
      echo "<a href='feature-edit.php?cmd=edit&id=$id'>$ft - Edit</a>";
      echo "<br>";
    }
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
   if (!isset($_POST["submit"]))
   {
      $id = $_GET["id"];
      $sql = "SELECT * FROM featured WHERE id=$id";
      $result = mysql_query($sql);        
      $myrow = mysql_fetch_array($result);
      ?>
  
      <form action="feature-edit.php" method="post">
      <input type="hidden" name="id" value="<?php echo $myrow["id"] ?>">
   
      Name:<INPUT TYPE="TEXT" NAME="ft" VALUE="<?php echo $myrow["ft"] ?>" SIZE=30><br>
      Picture:<INPUT TYPE="TEXT" NAME="fpic" VALUE="<?php echo $myrow["fpic"] ?>" SIZE=30><br>
      Text:<INPUT TYPE="TEXT" NAME="fw" VALUE="<?php echo $myrow["fw"] ?>" SIZE=30><br>
      More Link:<INPUT TYPE="TEXT" NAME="flink" VALUE="<?php echo $myrow["flink"] ?>" SIZE=30>
      <br>
      <input type="submit" name="cmd" value="edit">
   
      </form>
   
<? } ?>
<?
   if ($_POST["$submit"])
   {
      $ft1 = $_POST["ft"];
  $fpic1 = $_POST["fpic"];
  $fw1 = $_POST["fw"];
      $flink1 = $_POST["flink"];

mysql_query("UPDATE featured SET fpic='$fpic1', ft='$ft1', fw='$fw1', flink='$flink1' WHERE id='$id'") or die (mysql_error());
      echo "Thank you! Information on SPECIAL FEATURES updated.";
}
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/44432-can-anyone-see-the-problem/
Share on other sites

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/capetown/public_html/feature-edit.php on line 134

 

 

 

well the code is only 61 lines so error on 134 is weird

 

however this may reveal the problem

 

<?php
      $id = $_GET["id"];
      $sql = "SELECT * FROM featured WHERE id=$id";
echo $sql;
      $result = mysql_query($sql);        
      $myrow = mysql_fetch_array($result);

  
?>

Archived

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

×
×
  • 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.