limitphp Posted December 13, 2008 Share Posted December 13, 2008 I just uploaded my website to my live server. The address is www.greckle.com Its giving me the error: Warning: Cannot modify header information - headers already sent by (output started at /home/greckle0/public_html/connGreckle.php:11) in /home/greckle0/public_html/index.php on line 26 on line 26 I have this: setcookie("time",$time, 0); It works perfectly fine on the test server on wamp server 5.2.6 I did notice on my live server with lunarpages, it said php 4. something.....it wasn't version 5. Does anyone know why I'm getting this error? Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/ Share on other sites More sharing options...
T Horton Posted December 13, 2008 Share Posted December 13, 2008 Hi Have you tried putting in an "if" statement in your code to see if the cookie has been set already? If you submit your php code on here I can have a look for you. Tom Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714640 Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 That error means that you had some sort of output before the call to setcookie(). No output at all is permitted. Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714642 Share on other sites More sharing options...
corbin Posted December 13, 2008 Share Posted December 13, 2008 http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714644 Share on other sites More sharing options...
limitphp Posted December 13, 2008 Author Share Posted December 13, 2008 Yes. I do check for a cookie. Here's the whole section: //****************** HANDLE TIME ******************** //Get Existing time Value if($_GET['time']) $time = $_GET['time']; elseif($_COOKIE['time']) $time = $_COOKIE['time']; //Validate if(empty($time) || !is_numeric($time) || $time>365){ $time = 7; } //Set Cookie for next time setcookie("time",$time, 0); //LINE 26 //*********************************************** Whats wierd is, it works perfectly fine on wamp server. Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714645 Share on other sites More sharing options...
limitphp Posted December 13, 2008 Author Share Posted December 13, 2008 That error means that you had some sort of output before the call to setcookie(). No output at all is permitted. Here's the code up to that point: <?php include("connGreckle.php"); //LINE 1 $mode = $_POST['mode']; $logout = $_GET['logout']; $rememberMe = $_POST['remember']; $username = check_input($_POST['username']); $password = check_input($_POST['password']); $loginExist = 0; $loginFailed = 0; $genreList = "'Alternatve','Rock','Punk','Indie','Folk','Jazz','Blues','Reggae','RB','Pop','Country','Christian','Latin','Techno','Hip-Hop','World','Vocal','New Age'"; $allRock = $_POST['allrock']; $allGenres = $_POST['allGenres']; //******** HANDLE TIME **************************** //Get Existing time Value if($_GET['time']) $time = $_GET['time']; elseif($_COOKIE['time']) $time = $_COOKIE['time']; //Validate if(empty($time) || !is_numeric($time) || $time>365){ $time = 7; } //Set Cookie for next time setcookie("time",$time, 0); //LINE 26 I don't think there is any output before that cookie call?....... Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714647 Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 First of all, line 1 in that script is <?php. PHP's line numbers correlate exactly to a line in the file, not in the PHP tags. Second of all, with my telepathy and mind-numbingly incredible genius, I deduce that you have your editor set to save files in UTF-8. Look for an editor setting involving the UTF-8 BOM (byte order mark). Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714648 Share on other sites More sharing options...
limitphp Posted December 13, 2008 Author Share Posted December 13, 2008 ok, now the error is gone. In the connGreckle.php file I had some comments. I took them out, and now it works. huh....... Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714651 Share on other sites More sharing options...
limitphp Posted December 13, 2008 Author Share Posted December 13, 2008 First of all, line 1 in that script is <?php. PHP's line numbers correlate exactly to a line in the file, not in the PHP tags. Second of all, with my telepathy and mind-numbingly incredible genius, I deduce that you have your editor set to save files in UTF-8. Look for an editor setting involving the UTF-8 BOM (byte order mark). I'm sorry...you are correct..... the <?php was line 1. my mistake...I told you guys wrong.....sorry. Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714652 Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 My incredibly mind-numbing genius was on break when I made that post though. I didn't read the orig. error closely enough. It said the output was in connGreckle.php on line 11. Sorry. xD Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714653 Share on other sites More sharing options...
limitphp Posted December 13, 2008 Author Share Posted December 13, 2008 My incredibly mind-numbing genius was on break when I made that post though. I didn't read the orig. error closely enough. It said the output was in connGreckle.php on line 11. Sorry. xD So, comments are considered output.... Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714654 Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2008 Share Posted December 13, 2008 Edit: Wrote this before you made your last post DW. From the error message - output started at /home/greckle0/public_html/connGreckle.php:11 (line 11) Please read error messages. Sometimes they tell you not only what the problem is but where it is being caused at. Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714655 Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 My incredibly mind-numbing genius was on break when I made that post though. I didn't read the orig. error closely enough. It said the output was in connGreckle.php on line 11. Sorry. xD So, comments are considered output.... No, they're not. You must have not commented properly. o_O Unless it was an HTML comment, lol. THOSE are considered output. @PF: No problem. Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714662 Share on other sites More sharing options...
limitphp Posted December 13, 2008 Author Share Posted December 13, 2008 My incredibly mind-numbing genius was on break when I made that post though. I didn't read the orig. error closely enough. It said the output was in connGreckle.php on line 11. Sorry. xD So, comments are considered output.... No, they're not. You must have not commented properly. o_O Unless it was an HTML comment, lol. THOSE are considered output. @PF: No problem. Yeah...they were probably html comments. I don't remember. They are gone now anyway. : ) I wonder why it worked perfectly on wamp server, though? Link to comment https://forums.phpfreaks.com/topic/136835-solved-help-with-header-error/#findComment-714669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.