0

I have run into this problem in my Codeigniter app:

A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /application/controllers/training.php:1)
Filename: libraries/Session.php
Line Number: 671

I have been checking for whitespaces and I am not sending headers.

The ONLY way this error appears is when I am updating the view and controller files.

My code ran fine until I updated some files, then the error (above) refuses to disappear.

When I clear my cache and log back in again, the error doesn't show.

Does anyone know why?

17
  • 2
    What's on line 1 of training.php? Commented Sep 13, 2011 at 21:38
  • Also, what's up with this question's title? Commented Sep 13, 2011 at 21:47
  • @Cyclone Nothing ;-) (edited it) Commented Sep 13, 2011 at 21:51
  • 2
    @JamWaffles: Still doesn't make much sense, the user is asking about a header error, not xml Commented Sep 13, 2011 at 21:52
  • 3
    Swear to Cthulhu, next person asking a question about "headers already sent by" will get a downvote and a closevote. RTFM dangit. Commented Sep 13, 2011 at 21:54

3 Answers 3

2

May be UTF-8 BOM marker? Try saving training.php without BOM (if exists)

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

4 Comments

I am going to try that now, but how what that help? Just asking out of curiosity, because you must think it could be a reason.
I think you solved my problem! I never heard of BOM, but then i search for it, and find out that it can cause header already send! stackoverflow.com/questions/2558172/… "BOM would cause Headers already sent error, so, you can't use BOM in PHP files" - Now i have to create all my files again, damm.
This is a common problem... So, have you tried to save your file without BOM? Is this solved your issue?
someone should give bounty for this answer.
0

I'm not sure why it would appear and disappear like that, but you're sending output in /application/controllers/training.php on line one, which means that any script run after that cannot modify the header. Essentially, something is invoking CI's session library in a way which is modifying the header, but the header's been sent. It'd be helpful if we could see line one of training.php.

Comments

0

I have checked for whitespaces, none. I am not using session yet, i am only setting it to session variables in the login script. The ONLY place i use it.

training.php:

<?php

class Training extends CI_Controller
{

    public function index()
    {
        $data['heading'] = 'Træning';
        $data['smallheading'] = 'Registre dine træningsture og hold styr på dem.';
        $this->load->view('header_view', $data);
        $this->load->view('training_view');
        $this->load->view('footer_view');
    }

}

In the different views there is only echoing php variables and HTML.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.