Log in

View Full Version : Already Sent Headers



TimFA
02-23-2008, 05:03 AM
Ok, I know this problem is common. I read explanations EVERYWHERE. I tried using multiple different PHP editors to see if Notepad2 was lying and there was extra characters. But nothing, zip, zilch. Heres my code and the exact error log.



<?php
session_start();
$logged=$_SESSION['logged'];
$menu="<div class=\"linkbox\">
<a href=\"http://fassist.profusehost.net/\">
Home
</a>
</div>";

if ($logged=="yes") {
$menu=$menu.="<div class=\"linkbox\">
<a href=\"http://fassist.profusehost.net/userinfo\">
User info
</a>
</div>
<div class=\"linkbox\">
<a href=\"http://fassist.profusehost.net/logout\">
Logout
</a>
</div>";
}

else {
$menu=$menu.="<div class=\"linkbox\">
<a href=\"http://fassist.profusehost.net/login\">
Login
</a>
</div>";
}

print("$menu");
?>


(ignore the no such file or directory errors, I just haven't made a footer.php yet...)

[22-Feb-2008 20:59:25] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home/fassist/public_html/index.php:8) in /home/fassist/public_html/php/menu.php on line 2


[22-Feb-2008 20:59:25] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/fassist/public_html/index.php:8) in /home/fassist/public_html/php/menu.php on line 2


[22-Feb-2008 20:59:25] PHP Warning: main(php/footer.php) [<a href='function.main'>function.main</a>]: failed to open stream: No such file or directory in /home/fassist/public_html/index.php on line 42


[22-Feb-2008 20:59:25] PHP Warning: main(php/footer.php) [<a href='function.main'>function.main</a>]: failed to open stream: No such file or directory in /home/fassist/public_html/index.php on line 42


[22-Feb-2008 20:59:25] PHP Warning: main(php/footer.php) [<a href='function.main'>function.main</a>]: failed to open stream: No such file or directory in /home/fassist/public_html/index.php on line 42


[22-Feb-2008 20:59:25] PHP Warning: main() [<a href='function.include'>function.include</a>]: Failed opening 'php/footer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/lib/php/extensions:/usr/lib/php/extensions/no-debug-non-zts-20020429') in /home/fassist/public_html/index.php on line 42


EDIT: Also one time I read to use ob_start(); and ob_flush(); which had no effect, I check php.net and it said to use ob_end_clear() or something like that to silently delete it, tried and all it did was make the script not work at all.

jackbenimble4
02-23-2008, 06:21 AM
Is this menu.php? Can we see index.php? It looks like the output is being sent from index.php, and the code you referenced looks like it's menu.php.

TimFA
02-23-2008, 06:24 AM
DUHUR. It just hit me why, its because I'm including menu.php inside index.php which contains data...I suppose I'll have to reference it at the top, no printing just assign the variable then print within index.php. I think that should work.

Thanks man,
Tim

EDIT: and yes thats menu.php.