-1

Possible Duplicate:
PHP headers already sent

So I just joined Hostgator.com, and was wondering, why do I always get this error:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/kapip/public_html/main/mainpage.php:5) in /home/kapip/public_html/main/mainpage.php on line 7

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/kapip/public_html/main/mainpage.php:5) in /home/kapip/public_html/main/mainpage.php on line 7

What does this mean? I know I have to probably edit the php.ini, but I'm not sure what to change. Can anyone help me out? Thank you!

Community
  • 1
  • 1

3 Answers3

7

Make sure you don't have any whitespace or anything else displayed before you do session_start() e.g.

// whitespace, any mark up or include that displays something <HERE>
// it will give you that error
<?php
session_start();
tradyblix
  • 7,439
  • 3
  • 25
  • 29
2

This is a common problem. The call to session_start must happen before the first HTML tag or echo statement.

Incorrect:

<html>
<?php session_start() ?> 

Correct:

<?php session_start() ?>
<html>
Sam Magura
  • 850
  • 8
  • 18
0

Headers cannot be sent after output has started. Therefore, you should check /home/kapip/public_html/main/mainpage.php line 5 (which was indicated by the error message) for anything that results in output.

AndersTornkvist
  • 2,610
  • 20
  • 38