/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] "Cannot modify header information"?

On the top of my web page, I have this error message:

Warning: Cannot modify header information – headers already sent by (output started at /home/fgcomics/public_html/tester.php:6) in /home/fgcomics/public_html/tester.php on line 25

Code for top of page:

[CODE]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>FGComics.com :: TEMPLATE</title>
<?php
/* To add new skins, just put a new option in
the drop-down menu for it. Follow the format
of previous options. */

if (isset($_GET[“skinpref”]))
{
$skinpref = $_GET[“skinpref”];
}
elseif (isset($_COOKIE[‘skinpref’]))
{
$skinpref = $_COOKIE[‘skinpref’];
}
else
{
// Default style
$skinpref = blue;
}
// Set a cookie with the new style
setcookie(“skinpref”, $skinpref, time()+432000, “/”, “http://www.fgcomics.com”);
echo ‘<link rel=”stylesheet” type=”text/css” href=”http://www.fgcomics.com/css/fgcomics_’.$skinpref.’.css”>’.”n”;
?>
<script type=”text/javascript”>
<!—
function MM_jumpMenu(targ,selObj,restore)
{
eval(targ+”.location='”+selObj.options[selObj.selectedIndex].value+”‘”);
if (restore) selObj.selectedIndex=0;
}
//—>
</script>
<style type=”text/css”>
<!–
.style1 {color: #004182}
–>
</style>
</head>[/CODE]

Line 25:

[CODE]setcookie(“skinpref”, $skinpref, time()+432000, “/”, “http://www.fgcomics.com”); [/CODE]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@bokehJul 28.2005 — You cannot set a cookie after output has been sent to the client. Try putting the following right at the beginning of your script Before the html and any whitespace:

<?php ob_start(); ?>
Copy linkTweet thisAlerts:
@Funny_GuyauthorJul 28.2005 — It worked, but what was that?

ob_start();
Copy linkTweet thisAlerts:
@bokehJul 28.2005 — Output buffering. It stops any output being sent until after processing has been completed. This allows the output to be sent in the correct order even if it has been written in the wrong order.
Copy linkTweet thisAlerts:
@occultbirdOct 16.2005 — Unbelievable! I've searched for 12 hours to find your quick and easy answer.

[COLOR=Red][SIZE=5]
[CENTER]THANK YOU! THANK YOU!![/CENTER]
[/SIZE][/COLOR]
Copy linkTweet thisAlerts:
@kumaravasthiNov 14.2008 — You saved my Time.


It was the only post that I read for the solution of my problem and it solved the issue. ?
Copy linkTweet thisAlerts:
@MaroonblazerJul 03.2011 — You cannot set a cookie after output has been sent to the client. Try putting the following right at the beginning of your script Before the html and any whitespace:

<?php ob_start(); ?>[/QUOTE]


Thank you very much for this!
×

Success!

Help @Funny_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...