Forum Moderators: coopster

Message Too Old, No Replies

Cannot modify header information

         

superxtian

3:03 pm on Aug 30, 2008 (gmt 0)

10+ Year Member



The problems:

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\New Web\phpmygrades\lib\printlib.php:38) in C:\wamp\www\New Web\phpmygrades\lib\authlib.php on line 139

i think its all about whitespaces

so here is the code of printlib.php

function display_header($title)
{
$text = <<< EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>{$title}</title>
<meta http-equiv="content-language" content="en" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style/main.css" />\n
EOT;

// add the rss feed to the main page
if(strstr($_SERVER['SCRIPT_NAME'], "index.php") != FALSE)
{
$text .= "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS feed\" href=\"" . server_root . "news.php?xml&class=0\" />\n";
}

$text .= <<< EOT
<script type="text/javascript" src="scripts/main.js"></script>
</head>
<body>
<div class="container">
EOT;
print($text); // line 38
}

/**
* prints the basic webpage header
*/
function display_footer()
{
$text = <<< EOT
\n</div>
</body>
</html>
EOT;
print($text);
}

can someone help me to figure out whats the problem on the code?

eelixduppy

3:20 pm on Aug 30, 2008 (gmt 0)



I don't see a call to the function header [php.net]. If you do have one somewhere, though, in an included file, even, then you cannot have any output echoed to the browser before the function call, which includes HTML as well as even whitespace. Take a look and see if you can find where the output is coming from, and where you're actually header function is being called.

henry0

3:25 pm on Aug 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can not send a header when anything is called before the header is send
here you have a buch of HTML before sending your header
you may send a header whenever and wherever if in your php.ini you turn outputbuffering On.

if you do not have access to php.ini
ask your ISP about it or use .htaccess