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 Commented Apr 12, 2013 at 15:11
  • show us the Session.php file at line 675 Commented Apr 12, 2013 at 15:11
  • 1
    lol, dont delete it, give at least one vote to Jonh Conde who helped you! Commented Apr 12, 2013 at 15:13
  • @Tomás I given him vote. Thank you 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.

Sign up to request clarification or add additional context in comments.

8 Comments

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.
@phpNoOb So what should i do in that line? Shall i give more space or shall give no space before php opne tag <?php
@BurlsWillis no space, remove al. Updated my original answer with an explanation.
yes Its a Whitespace error before <?php tag...
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.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.