everything is updated...help!
Posted: Tue Mar 22, 2005 4:07 am
i have a script that edit the content the comment and updates the database....
my problem is that, when there are two or more comments, then i want to update one comment, all the comments are updated....
Code: Select all
<?
$cid = $_GET['cid'];
if (isset($_POST['submit']))
{
$message = NULL;
if (empty($_POST['comment']))
{
$c = FALSE;
$message .= 'Please enter your comment!<br>';
}
else
{
$c = addslashes($_POST['comment']);
}
$updatequery = "UPDATE posts SET postupdate=NOW() WHERE postID='".$cid."'";
$updateresult = @mysql_query($updatequery);
$query = "UPDATE comments SET comment='$c' WHERE postID='".$cid."'";
$result = @mysql_query($query);
if ($updatequery && $result)
{
echo '<b/>Your comment has been posted!';
echo '<meta http-equiv="refresh" content="3;url=http://localhost/mysample/report.php">';
exit();
}
else
{
echo 'Your comment cannot be posted due to system error!'.mysql_error();
}
//mysql_close();
}
if (isset($message))
{
echo '<font color="red">', $message, '</font>';
}
?>