fogofogo Posted December 12, 2005 Share Posted December 12, 2005 Hello All,I have a page that passes a session variable to another page which is then used in an if/else statement. For some reason itsa giving me error messages, and I'm not sure whats up with it.Heres the page that creates the variable <?phpsession_start(); // start session$_SESSION['name'] = 'sport';?> and heres the page with the if else statment : <?phpsession_start();$_SESSION['name'];//$name = 'Jester';if ( $name == 'sport' ) { ?><table>stuff in here</table><? } else { ?><table>stuff in here</table><? } ?>and finally - here are the error messages that I am getting :Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\wamp\www\work\hebbingo\site\test.php:11) in c:\wamp\www\work\hebbingo\site\test.php on line 13Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\wamp\www\work\hebbingo\site\test.php:11) in c:\wamp\www\work\hebbingo\site\test.php on line 13As you've guessed, I'm pretty new to this so I have probably missed something basic - any ideas?CheersFogo Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 12, 2005 Share Posted December 12, 2005 The error says you haven't written the session_start() at the VERY beginning of your document. There must be absolutely NO Html before, even no space. So check if it does not begin with <?php, and correct it :)If the opening PHP tag of the section in which the session is started sents HTML, this is also not allowed. session_start should be the very much first command in PHP, that way you can't make any mistake Note: you can recognise this very common error by headers already sent by somewhere in the message Link to comment Share on other sites More sharing options...
fogofogo Posted December 16, 2005 Author Share Posted December 16, 2005 The error says you haven't written the session_start() at the VERY beginning of your document. There must be absolutely NO Html before, even no space. So check if it does not begin with <?php, and correct it :)If the opening PHP tag of the section in which the session is started sents HTML, this is also not allowed. session_start should be the very much first command in PHP, that way you can't make any mistake Note: you can recognise this very common error by headers already sent by somewhere in the message <{POST_SNAPBACK}> nice one man - all fixed! Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 16, 2005 Share Posted December 16, 2005 Glad to serve Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now