I have this code but whenever i enter an id of an entry to edit I get this error
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/refresh/public_html/blog-edit.php on line 30
I know I am entering an ID that exists
[code=php]
<?
global $pageTitle;
$pageTitle=”ComplexFellow.com::Edit Entry”;
include(“header.php”);
?>
<div class=”content”>
<form action=”<?$_SERVER[‘PHP_SELF’];?>” method=”post”>
<div>
<?
$un = “”;
$pass = “”;
$db = “”;
$host = “”;
$sql = mysql_connect($host, $un, $pass) or die(mysql_error());
if($submit==””)
{
?>
<form action=”<?$_SERVER[‘PHP_SELF’];?>” method=”post”>
Enter ID of entry to edit
<br />
<input type=”text” name=”ID” /><br />
<input type =”submit” name=”submit” value=”submit” class=”submit” />
</form>
</div>
<?
}
elseif($submit !=””)
{
$ID=$_POST[‘ID’];
$query = “SELECT * FROM blog WHERE ID='”.$ID.”‘”;
$result=mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$id=$row[‘ID’];
$content=$row[‘content’];
$title=$row[‘title’];
?>
<div>
<form action=”<?$_SERVER[‘PHP_SELF’];?>” method=”post”>
<?
echo”<input type=’text’ name=’blogtitle’ value=$blogtitle />”;
echo”<textarea rows=’20’ cols=’50’ name=’blogcontent’>$content</textarea>”;
echo'<input type =”submit” name=”edit” value=”Edit!” class=”submit” /></form></div>’;
$query = “UPDATE `blog` SET `content` = ‘$blogcontent’ WHERE `ID` = ‘$id’ LIMIT 1”;
}
}
?>
<?include(“footer.php”);?>