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 General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Message: Cannot modify header information - headers already sent (/showthread.php?tid=30438)

Pages: 1 2


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]chicadeas[/eluser]
I know I am going to get some ugly replies to this post but I have searched past posts and have had no luck. I have had this problem before with blank spaces before or after php tags but that's not the problem this time. Here is the code in my controller and view files.

Code:
<?php
class Blog2 extends Controller
{

function Blog2 ()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
}

function index ()
{
$data['title'] = "My blog title";  
$data['heading'] = "My Blog Heading";
$data ['query'] = $this->db->get('entries');

$this->load->view('blog2_view', $data);
}
}


Code:
<html>
<head>
<title><?php echo $title?></title>    
</head>
<body>
<h1>&lt;?php echo $heading?&gt;</h1>    

&lt;?php foreach($query->result() as $row): ?&gt;    
<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>

<p>&lt;?=anchor('blog2/comments/'.$row->id, 'Comments');?&gt;</p>

<hr>
&lt;?php endforeach; ?&gt;
&lt;/body&gt;
&lt;/html&gt;



Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]WanWizard[/eluser]
There's nothing here that would modify the header, so I assume there is more code.

If you get this error, it usually says exactly in which file and on what line the error occurred? While file and line is that?


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]chicadeas[/eluser]
This is the full message:

Message: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web214/b2141/ipg.tidetigercom/system/application/controllers/blog2.php:1)


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]WanWizard[/eluser]
What editor do you use? My first guess would be a Windows editor that creates UTF-8 files with a BOM header.

Check the file, and remove the BOM (most editors allow you to switch that off, if not, switch editors Wink)


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]chicadeas[/eluser]
Thanks WanWizard. I was using the FlashDevelop editor to get the error. I transferred the code to OpenOffice Writer and now it works perfectly. What editor do you reccomend.


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]pickupman[/eluser]
[quote author="chicadeas" date="1273891870"]Thanks WanWizard. I was using the FlashDevelop editor to get the error. I transferred the code to OpenOffice Writer and now it works perfectly. What editor do you reccomend.[/quote]

That's kind of like asking, what car should I drive? It's all based on preferences. I could recommend Notepad++ for the barebones, and Netbeans for a good free php IDE.


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]theprodigy[/eluser]
+1 for both of those.

I am on a linux box, so I use Netbeans for majority of stuff, but when a quick fix is needed I typically use vim. But when on a Windows box, Netbeans and Notepad++ work just as well.


Message: Cannot modify header information - headers already sent - El Forum - 05-14-2010

[eluser]chicadeas[/eluser]
This forum is unbeliveable. The responses are fast and the repliers sure know their stuff. Thank God for CodeIgniter.


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

[eluser]WanWizard[/eluser]
In the 'old' days on Windows I used UltraEdit. Now, on Linux, I simply use Geany (in combination with my favorite subversion client, SyncroSVN).


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

[eluser]Zack Kitzmiller[/eluser]
From what my PyroCMS peers tell me, NetBeans is the goto editor on Win/Linux.

I use Coda and TextMate on the Mac.