954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

header information error

I have this header information error while I was playing with a script.

Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/layouts/connection.php:8) in /home/user/public_html/layouts/addcomments.php on line 23

I wanted the page to redirect itself after submitting the comment, but I messed up.
I also want to know how do I make the url text area capible of accepting urls and emails.
addcomments.php
[PHP]<?php
include('connection.php');
$action = strip_tags($_GET["action"]);
$id = strip_tags($_GET["id"]);

if ($action=="add")
{
$name = strip_tags($_POST["name"]);
$entry = strip_tags($_POST["entry"]);
$email = strip_tags($_POST["email"]);

// add comments
if (empty($name) || empty($entry))
{
die ("Error, you cannot submit a blank entry.");
}

$q = "insert into layout_comments (id, name, email, date, layout_id, entry) VALUES

('','$name','$email',now(),'$id','$entry')";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());
if ($result)
{
header('Location: addcomments.php');

}

}
else {


?>" method="post">
Add Comments
Name:*


Url:


Comments:*



<?php
}
?>
<?
$id = strip_tags($_GET["id"]);

$q = "SELECT * from layout_comments where layout_id='$id' order by date desc ";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());


while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$name=$row["name"];
$email=$row["email"];
$entry=$row["entry"];
$date=$row["date"];
$layout_id = $row["layout_id"];

?>

Comments for <?php echo "$title"; ?>

<?php echo "$entry"; ?>
Posted by "><?php echo "$name"; ?> on <?php

echo "$date"; ?>.




<?php
}


?>[/PHP]

Yuki H.
Light Poster
26 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

In a quick glance at your code, it does not appear that your are outputting anything before you attempt the header() function. So, my guess is either:

1. connection.php is outputting something using echo(), print(), etc.
2. You have whitespace before or after the initial and final <?PHP ?> tags in the connection.php include file.

I do not understand what you are asking here:...how do I make the url text area capible of accepting urls and emails. It will accept a URL or email address---anything your user can type on the keyboard can be typed into that text input.

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You