its a header error, but i cant figure out whats wrong, im trying to add a comment to news, but it gives me a error, and when i go back to look at the news and what comments are on it, it only shows the name, not the comment
Quote
Warning: Cannot modify header information - headers already sent by (output started at /home/cory/domains/gamingreloaded.com/public_html/newscomments/news.php:5) in /home/cory/domains/gamingreloaded.com/public_html/newscomments/news.php on line 53
<?php
include 'dbconnect.php';
$sql = mysql_query("SELECT * FROM news WHERE id = ".$_GET['id']);
if($sql == 0){
echo "<br /><br />Cannot Find News Item. <a href=\"show.php\">Go Back?</a>";
}else{
while($r=mysql_fetch_assoc($sql))
{
$id=$r["id"];
$title=$r["title"];
$newstext=$r["newstext"];
$postdate=$r["postdate"];
$icon=$r["icon"];
$username=$r["username"];
$news = nl2br("$newstext");
echo "<img src=\"$icon\" class=\"newsicon\" alt=\"\" /> \n";
echo "<br /><b>:: $title</b> // Posted By <b>$username</b><br /> \n Posted on <b>$postdate</b><br class=\"clear\" /> \n";
echo "$news<br class=\"clear\" /><br /> \n";
}}
?>
<b>Comments:</b><br />
<?php
$sql = mysql_query("SELECT * FROM comments WHERE commentid = ".$_GET['id']);
if($sql == 0){
echo "<b>No Comments Yet</b>.";
}else{
while($r=mysql_fetch_assoc($sql))
{
$comment=$r["comment"];
$commentauthor=$r["commentauthor"];
$comment1 = htmlspecialchars("$shout1", ENT_QUOTES);
$comments2 = nl2br("$comment1");
echo "<div>:: $commentauthor</div> \n";
echo "<div>$comments2</div> \n";
}}
?>
<?php
if($_POST['comments'])
{
if (empty($_POST['commentauthor'])) {
echo"You Forgot To Enter A Name! Please <a href=\"javascript:history.go(-1);\">Go Back</a> And Add One!";
exit; }
elseif (empty($_POST['comment'])) {
echo"You Forgot To Enter A Message! Please <a href=\"javascript:history.go(-1);\">Go Back</a> And Add One!";
exit; }
elseif ($_POST['commentauthor'] == "Nickname") {
echo"You Forgot To Enter A Name! Please <a href=\"javascript:history.go(-1);\">Go Back</a> And Add One!";
exit; }
elseif ($_POST['comment'] == "Comment") {
echo"You Forgot To Enter A Message! Please <a href=\"javascript:history.go(-1);\">Go Back</a> And Add One!";
exit; }
$result=MYSQL_QUERY("INSERT INTO comments (commentauthor,commentid,comment)"."VALUES ('$commentauthor','$commentid','$comment')");
header("Location: ". $_SERVER['HTTP_REFERER']);
}
?>
<form action="<?php echo"{$_SERVER['PHP_SELF']}" ?>" method="post">
<p>
<input onfocus="if (value=='Nickname') value='';" onblur="if(value=='') value='Nickname';" size="50" type='text' value='Nickname' name='commentauthor' maxlength='100' />
<textarea onfocus="if (value=='Nickname') value='';" onblur="if(value=='') value='Nickname';" name="comment" rows="5" cols="50">Comment</textarea>
<input class="hide" type="hidden" name="commentid" value="<?php $echoit=$_GET['id']; echo"$echoit"; ?>" />
<input type="submit" name="comments" value="Add Tag" />
</p>
</form>
line 5:
echo "<br /><br />Cannot Find News Item. <a href=\"show.php\">Go Back?</a>";
and line 53:
header("Location: ". $_SERVER['HTTP_REFERER']);
