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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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?....... Quote Link to comment 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). Quote Link to comment 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....... Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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.... Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.