-4

Possible Duplicate:
Cannot modify header information - headers already sent, Why its happening
Headers already sent by PHP

Error on the all pages on my website.

 Warning: Cannot modify header information - headers already sent by (output started at        
    /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 75

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5228

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5228

Warning: Cannot modify header information - headers already sent by (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5232

Warning: Cannot modify header information - headers already sent by (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5272

Above warning is giving on my all pages on my website . I have remove spaces and echo which reflect the header tag, I have searched also but no luck at all. Please help me.

Community
  • 1
  • 1
Gopal
  • 47
  • 1
  • 5
  • 2
    If you type this "[php] headers already sent" to the SO search, you will find thousand of this identical questions... Let me help you with the search > http://stackoverflow.com/a/8028987/67332 – Glavić Sep 21 '12 at 07:23
  • If you read the error message you'll see that you have output in directyourmoney/common.htm at line 3 – Musa Sep 21 '12 at 07:27

3 Answers3

0

Give us your code if you want a more specific help.

However, this means that you're trying to modify the header (for example with the header function or the setcookie one` after that you've already sent some html lines. This is not allowed.

In your case, you're trying to start a new session and this operation needs to send a cookie. This is why in the documentation is clearly stated that if you want to start a new session, you should add session_start at the top of your page.

If you want to modify the header, you have to do it before printing anything else.

Zagorax
  • 11,440
  • 8
  • 44
  • 56
  • @Ninsuo, Yes, you're right. I didn't noticed that before as the answer to the question was quite obvious. However, edited to reflect this specific case. :D – Zagorax Sep 21 '12 at 07:26
0

You can't use session_start() after any html output

This will work:

<?php
    session_start();
    $some_value = 'something';
?>

This will not work:

<?php
    $some_value = 'something';

    echo $some_value;

    session_start();
?>
Mihai Matei
  • 24,166
  • 5
  • 32
  • 50
0

The below could both cause the issue you are posting about...

<html>
<head>
<title>blah</title>
<body>
    <?php

            session_start();
        header("Location: http://www.google.com");
        exit();
    ?>
</body>
</html>

or as Matei Mihai said

<?php
    $some_value = 'something';

    echo $some_value;

    session_start();
?>
Chris
  • 5,516
  • 1
  • 26
  • 30
  • ode- if(!session_id())session_start(); this is the line 5218 @$data['sid']=session_id(); header("Cache-control: private"); // this is the line 5222 and another code- if($data['ReferralPays']){ if(get_member_id($post['sponsor'], '', "`active`=1")){ $_SESSION['sponsor']=$post['sponsor']; setcookie('rid', $post['sponsor']); // this is the line 5266 }elseif(!$_POST['sponsor'])unset($post['sponsor']); }unset($_POST['sponsor']); – Gopal Sep 21 '12 at 07:56