Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/box/public_html/im/launch.php:29) in /home/box/public_html/im/launch.php on line 40
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/box/public_html/im/launch.php:29) in /home/box/public_html/im/launch.php on line 40
Warning: Cannot modify header information - headers already sent by (output started at /home/box/public_html/im/launch.php:29) in /home/box/public_html/im/launch.php on line 42
Warning: Cannot modify header information - headers already sent by (output started at /home/box/public_html/im/launch.php:29) in /home/box/public_html/im/launch.php on line 43
Make sure you have nothing that outputs to the browser before those lines and delete any unessasary whitespace from that code up. That error means you outputted something to the browser before line 40 and then tried to use a header value that can't be sent because of course the header had already been sent before line 40.
I know this is an old post, but I got the same problem:
error: arning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /mnt/w0207/d23/s08/b02d7009/www/designisbs.ca/johnbursic/edit_profile_verification.php:21) in /mnt/w0207/d23/s08/b02d7009/www/designisbs.ca/johnbursic/edit_profile_verification.php on line 25
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/w0207/d23/s08/b02d7009/www/designisbs.ca/johnbursic/edit_profile_verification.php:21) in /mnt/w0207/d23/s08/b02d7009/www/designisbs.ca/johnbursic/edit_profile_verification.php on line 25
Code:
PHP Code:
<?php
$form_username = $_POST['username'];
session_start();
if(!empty($_POST['surname'])){
foreach($_POST as $key => $value) {
$_SESSION['profile'][$key] = mysql_real_escape_string($value);
}
$fields = array("surname", "givenName", "homeSuite", "mailSuite", "homeAddy", "mailAddy", "homeCity", "mailCity", "homeProv", "mailProv", "homeCount", "homePost", "mailPost", "busPhone", "celPhone", "homPhone", "fax", "busEmail", "perEmail");
$sql .= "UPDATE users SET ";
$length = count($fields);
$n = 1;
foreach($fields as $field) {
if($n < $length) {
$sql .= "{$field}='{$_SESSION['profile'][$field]}',";
} else {
$sql .= "{$field}='{$_SESSION['profile'][$field]}'";
}
$n++;
}
$sql .= " WHERE username = '{$username}'";
if(mysql_query($sql, $link)){
// Successfull - Clear the Session
$_SESSION['profile'] = NULL;
echo("<p>{$form_username}'s Details have been saved.</p>\n");
}else{
$error = mysql_error();
echo("<p>There was an Error saving {$form_username}'s Details.</p>\n<p>{$error}</p>\n");
}
}else{
echo("<p>Please make sure all Required fields are Vaild</p>\n");
}
?>
The answer is exactly the same as was given before. Check edit_profile_verification.php line 21 and see what it is sending to the browser. Remove that, and it should fix it.
Blank space above the php tag or below the final php tag
It is not intuitive but ...
if <?php is at line 2 of your script and a blank line is above it then that can cause problems such as the php header function not working.
I had a HEADER session_regenerate error because a script called by require_once () or include () had 1 blank line below the closing php tag !!
?>
BLANK LINE WAS HERE
echo statements will also be a problem if they precede the header function call.
I wonder if die() or any other statements which write to the screen would be just as bad as echo () in this situation.
i get the same message using dreamweavers built-in log-in wizard
Hi, I used Dreamweavers "Log-in User" wizard to create the php code that binds to the database and upon execution, i get the following message:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent in /Users/xxx/Sites/xxxx/login.php on line 10
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/xxx/Sites/xxxx/login.php:10) in /Users/xxx/Sites/xxxx/login.php on line 10
In at least a couple places before the session_start(), you have this sort of thing going on:
PHP Code:
<?php // some code ?> <?php // some more code . . . ?>
The newline between the "?>" and the subsequent "<?php" is, in fact, output. Either get rid of those superfluous closing/opening php tags, or - probably better in the long run - move the session_start() to be in the very first <?php...?> section.
Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett
"But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html
I am also getting this error. I've looked around for a while and haven't figured out how to fix it, but my errors are for all of my PHP code. This is kind of weird. So here is my code.
Code:
<?php session_start();?><html><?php
if(isset($_SESSION['loggedinuser']))
echo "You're logged in! Click <a href='profile.php'>Here</a> to view your profile";
else {
echo "You're not logged in. Do you want to <a href='login.php'>log in</a> or <a href='register.html'>register</a>?";
}
?>
<head>
<title>UrComics.com Your comics, Your votes!</title>
<link rel="stylesheet" type="text/css"
href="style.css" />
</head>
<body>
<table border="1" cellspacing="0" cellpadding="1" align="left">
<tbody>
<tr>
<td>
<img alt="" src="./Images/UrComicsLogo1.gif" />
<br />
<h5 align="center">
<a href="index.php">Home</a>
<br />
<a href="UrPaper.php">Ur Paper</a>
<br />
<a href="inThePaper.php">In The Paper</a>
<br />
<a href="Help.html">Help/FAQ</a>
<br />
<a href="uploadcomic.php">Submit A Comic</a>
</h5>
</td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="2" cellpadding="2" align="center" width="75%">
<tbody>
<tr>
<td>
<h1 align="center">Welcome to UrComics.com</h1>
</td>
<td>
<h3>Hits</h3>
<hr align="left" width="100%" "noshade" size="2" />
<h3>
<?php
$filename = "counter.txt" ;
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
echo "$fstring" ;
fclose ($fd) ;
$fd = fopen ($filename , "w") or die ("Can't open $filename") ;
$fcounted = $fstring + 1 ;
$fout = fwrite ($fd , $fcounted) ;
fclose ($fd) ;
?>
</h3>
<br />
</td>
</tr>
<tr>
<td width="50%" class="red">
<h3 align="center">Announcements</h3>
<hr align="left" width="100%" "noshade" class="red" size="2" />
<br />
<p>Welcome to urcomics.com where you can post your own comics and see what others think of your idea.
Just create an account to get started!</p>
<a href="register.html">Click Here to Get Started!</a>
</td>
<td width="50%" class="blue">
<h3 align="center">Comics Of The Week</h3>
<hr align="left" width="100%" "noshade" class="blue" size="2" />
<br />
<p>Once I figure out the php i am gonna put the top rated comics of the week on here.</p>
</td>
</tr>
<tr>
<td class="green" align="left">
<h3 align="center">Login</h3>
<hr align="left" width="100%" "noshade" class="green" size="2" />
<br />
<?php
if(isset($_SESSION['loggedinuser'])) {
?>
You're currently logged in, do you want to <a href="logout.php">Log out</a>?
<?php
} else {
?>
<p>Put in your username and password to login.</p>
<br />
<form name="authenticate" method="post" action="authenticate.php">
Username:<input name="username" type="text" size="20">
<br />
Password:<input name="password" type="password" size="20" />
<br />
<input type="submit" name="submit" value="submit"/>
<input type="reset" name="clear" value="reset"/>
</form>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</body>
</html>
So I am getting these errors at the top of my page.
Code:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\file\secret\index.php:1) in C:\anotherfile\file\index.php on line 1
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\files\morefiles\index.php:1) in C:\morefiles\stuff\index.php on line 1
NOTE:That is not really the file location.
But it is weird because the code was working then it just stopped working. and none of my php works so I don't know if this is a problem in my php.ini file or what. Anyone know how to fix this?
Some editors, when they save a file as UTF-8, stick extra characters into the file at the very beginning (the format doesn't require it, but they do it anyway). Then refuse to show you those characters when they display the file. To see if your editor is one of these, try saving an empty file and seeing how many bytes it takes up. If it's more then zero (probably three), then you'll have to tell your editor to stop messing around (and how you do that depends on the editor).
Last edited by Weedpacket; 12-28-2008 at 07:08 PM.
I don't think so... I am using Microsoft Visual web studio and it doesn't do that because when I wrote this code I wrote it in notepad so It shouldn't be that that is happening.
The error message is specifically telling you that something on line 1 of the script generated output prior to the session_start() call. Either there is something before the opening <?php tag (a space, a newline, a unicode BOM character), or the only other thing I can think of would be if your PHP configuration has an auto_prepend_file specified and that file is generating output, although in that case I think the error message would point to that file instead (though I'm not 100% sure about that).
Therefore pending any further information, I suspect Weedpacket's suggestion is correct, that your editor is saving the file in UTF-8 with a BOM (byte order mark) at the start of the file. Either see if there is an option with your editor to save it as plain ASCII or as UTF-8 without the BOM, or else try another editor that can.
Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett
"But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html
Yes, Notepad is one of those editors that does this (unless you save the file with an ANSI character set). Visual Studio also provides the option, but if I recall, for HTML files it defaults to Latin-1 and you have to tell it to use UTF-8 (with BOM).
Ok so I saved a blank file and it put 3 bytes and said 1 kb so I do think you are right. So I don't think notepad does that so I am probably going to edit it in there. But is there some way to change the code to have nothing in front of it? because in notepad I see nothing so do you guys think the best way to do this would to open a new notepad file and copy the code down?
Sorry for double posting but I just wanted to say thanks for helping me out. I rewrote the code in notepad and it worked! So I just gotta rewrite each page w/ php on it... But anyway thanks again.
Bookmarks