sophielulu Posted March 21, 2007 Share Posted March 21, 2007 Please Help!!! here is my entire file <?php ob_start(); setcookie('username', 'admin'); ?> I get the headers already sent message. Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/o/p/sophielulu/html/csc401/class/setcookie.php:1) in /home/content/s/o/p/sophielulu/html/csc401/class/setcookie.php on line 1 I have read the postings and nothing is being sent before this line and I've added the ob_start(). Not sure what to try next........ Link to comment https://forums.phpfreaks.com/topic/43711-solved-headers-already-sent-i-did-read-the-postings-but-still-happening/ Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 Make sure there is no space at the top of the file IE: <?php /// this will throw an error ?> <?php /// this will not throw an error ?> Link to comment https://forums.phpfreaks.com/topic/43711-solved-headers-already-sent-i-did-read-the-postings-but-still-happening/#findComment-212203 Share on other sites More sharing options...
kenrbnsn Posted March 21, 2007 Share Posted March 21, 2007 That should work. Sometimes whatever editor you're using puts an unprintable character before the initial "<?php" which will cause this problem. Retype everything into a new file. Also, instead of putting everything on one line, make multiple lines: <?php ob_start(); setcookie('username', 'admin'); ?> This way the error message might actually point to the correct line. Link to comment https://forums.phpfreaks.com/topic/43711-solved-headers-already-sent-i-did-read-the-postings-but-still-happening/#findComment-212208 Share on other sites More sharing options...
sophielulu Posted March 21, 2007 Author Share Posted March 21, 2007 thank you. When I retyped in another editor the problem went away. Link to comment https://forums.phpfreaks.com/topic/43711-solved-headers-already-sent-i-did-read-the-postings-but-still-happening/#findComment-212260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.