CodeIgniter Forums
Message Cannot modify header information - headers already sent - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Message Cannot modify header information - headers already sent (/showthread.php?tid=5362)

Pages: 1 2 3 4


Message Cannot modify header information - headers already sent - El Forum - 01-20-2009

[eluser]marciol[/eluser]
I have changed only $config['base_url'] ="http://localhost/ci/";-so what's wrong?


Message Cannot modify header information - headers already sent - El Forum - 01-20-2009

[eluser]JoostV[/eluser]
Have you checked to see if there is white space before the <?php openingtag in line 1?


Message Cannot modify header information - headers already sent - El Forum - 01-20-2009

[eluser]marciol[/eluser]
there is no white space before the <?php openingtag in line 1

<?php if(!defined('BASEPATH'))exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
*/
$config['base_url'] ="http://localhost/ci/";
/*


Message Cannot modify header information - headers already sent - El Forum - 01-20-2009

[eluser]JoostV[/eluser]
Copy a fresh config.php into system/application/config/ and see if you still get an errro message. Edit config.php afterwards.


Message Cannot modify header information - headers already sent - El Forum - 01-25-2009

[eluser]Unknown[/eluser]
got a similar problem:

Quote:Message: Cannot modify header information - headers already sent by (output started at C:\sandbox\ignite\system\application\controllers\blog.php:1)

Filename: helpers/url_helper.php

Line Number: 530

I've checked for whitespace in my blog.php but i don't see any. help?


Message Cannot modify header information - headers already sent - El Forum - 02-08-2009

[eluser]Unknown[/eluser]
[quote author="jsonar" date="1232886631"]got a similar problem:

Quote:Message: Cannot modify header information - headers already sent by (output started at C:\sandbox\ignite\system\application\controllers\blog.php:1)

Filename: helpers/url_helper.php

Line Number: 530

I've checked for whitespace in my blog.php but i don't see any. help?[/quote]

Hi,
I had same problem so I tried change coding of blog.php file
and problem resolved


Message Cannot modify header information - headers already sent - El Forum - 02-22-2009

[eluser]thephpx[/eluser]
Hi guys,

Do not know if it will help or not but I was getting the same kinda error.
<-- CODE START --&gt;
function addlession(){
$this->template->type('back');
$this->template->set('admin');
$this->template->load('top', $page);
$this->template->load('lessonsadd', $page);
$this->template->load('bottom');

if(count($_POST) > 1)
{
//do things.
}
}
<-- CODE END --&gt;

upon posting the values to this same function it was showing "Cannot modify header information - headers already sent by...". Loading the template files after the if statement seems to fixed this problem.

In my case it happened because the header was already sent while parsing the templates, not because of any white-space but yes 99% case it happens because of 1 extra line before &lt;?php or after ?&gt; tag.

So to solve this issue I loaded the templates after the if statement Smile

<-- CODE START --&gt;
function addlession(){
$this->template->type('back');
$this->template->set('admin');

if(count($_POST) > 1)
{
//do things.
}
$this->template->load('top', $page);
$this->template->load('lessonsadd', $page);
$this->template->load('bottom');
}
<-- CODE END --&gt;

take care,

faisal


Message Cannot modify header information - headers already sent - El Forum - 03-14-2009

[eluser]Unknown[/eluser]
Hi,

I had similar problem and I would like to share info on my case Smile

I was trying to implement JSON reply with CodeIgniter but when I try to change the headers using "header("content-type:application/json")";, I got the following unexpected response.

Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\filemoo\system\application\controllers\vote.php:1)

Filename: controllers/vote.php

Line Number: 21

I then change the file encoding from UTF-8 to ANSI using Notepad++, a free text editor. And the error was gone Smile

But since I am in Asian countries, I do need UTF-8 support. So I changed the encoding from UTF-8 to UTF-8 without BOM. And then everything is going as expected. The BOM (Byte-order mask) at the beginning of UTF-8 file maybe the culprit.


Message Cannot modify header information - headers already sent - El Forum - 05-15-2009

[eluser]Unknown[/eluser]
Some of CodeIgniter Core files are in UTF-8 encoding. Covert all of your (and CI) files to UTF-8 without BOM, like m3rLinEz says...Notepad++ come in hand, at all. The people that uses Dreamweaver, for example, can get some problems with encoding. Then, convert all files before the tests or deployment.


Message Cannot modify header information - headers already sent - El Forum - 07-16-2009

[eluser]peroperje[/eluser]
thanks man...you help me too