|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
"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:
setcookie("skinpref", $skinpref, time()+432000, "/", "http://www.fgcomics.com");
|
|
#2
|
||||
|
||||
|
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(); ?> |
|
#3
|
||||
|
||||
|
It worked, but what was that?
ob_start(); |
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
|||
|
|||
|
Thank you
Unbelievable! I've searched for 12 hours to find your quick and easy answer.
THANK YOU! THANK YOU!!
|
|
#6
|
|||
|
|||
|
You saved my Time.
It was the only post that I read for the solution of my problem and it solved the issue.
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|