13

I have created a dynamic menu CMS website. I developed in a Windows system. When i run my project in windows operating system, My project runs without any error. But now uploaded it into Linux Operating system server i am getting warning & error like:

    A PHP Error was encountered

    Severity: Warning

    Message: Cannot modify header information - headers already sent by (output started at /home/ansofcm8/public_html/apps/resources/math/application/core/MY_Controller.php:1)

    Filename: libraries/Session.php

    Line Number: 675

What could be the reason. Please help me.

4
  • @JohnConde Thank you . I will delete this question after solving this issue
    – Dan
    Commented Apr 12, 2013 at 15:11
  • show us the Session.php file at line 675
    – Tomás
    Commented Apr 12, 2013 at 15:11
  • 1
    lol, dont delete it, give at least one vote to Jonh Conde who helped you!
    – Tomás
    Commented Apr 12, 2013 at 15:13
  • @Tomás I given him vote. Thank you
    – Dan
    Commented Apr 12, 2013 at 15:24

1 Answer 1

36

There seems to be whitespace before the php open tag <?php in MY_Controller.php.

Check all PHP files and remove the whitespace before the <?php tag. If there is a space or new line, the body of the http request is started, and you can't add new headers to the http request.

8
  • 1
    Yep, is a whitespace. @Burls Willis check headers already sent by (output started at MY_Controller.php:1). It's pointing to line 1, and the only thing that is sending something to the frontend on the first lines in a php file are whitespaces.
    – Tomás
    Commented Apr 12, 2013 at 15:16
  • @phpNoOb So what should i do in that line? Shall i give more space or shall give no space before php opne tag <?php
    – Dan
    Commented Apr 12, 2013 at 15:20
  • @BurlsWillis no space, remove al. Updated my original answer with an explanation.
    – JackPoint
    Commented Apr 12, 2013 at 15:21
  • 1
    yes Its a Whitespace error before <?php tag... Commented May 27, 2013 at 11:18
  • 1
    For my issue, I had a php cron task that hit that controller every 5 minutes to run a function. That php cron file caused the session headers already sent issue. I had to move my session_start in that controller into a function that was NOT called by the cron php task. That fixed it.
    – Robot70
    Commented May 10, 2016 at 16:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.