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: Cannot modify header information - headers already sent (/showthread.php?tid=41173) Pages:
1
2
|
Cannot modify header information - headers already sent - El Forum - 04-30-2011 [eluser]Sudz[/eluser] I tried man, But still giving the same error A PHP Error was encountered Severity: Warning Message: Cannot modify header information - headers already sent Filename: helpers/my_userExel_helper.php Line Number: 494 Cannot modify header information - headers already sent - El Forum - 04-30-2011 [eluser]toopay[/eluser] I don't know your whole library looks like and how its flow process. Also is there are loop or nested loop inside your library. You can working around it with ob_clean(), ob_flush(), proper validation(headers_sent()), save the header in some array variable(apache_response_headers()), and so on. Just make sure you send the header before send out the buffer Cannot modify header information - headers already sent - El Forum - 04-30-2011 [eluser]toopay[/eluser] In addition, you may look at CI core class, and make sure your ob_start(), ob_end_clean() didnt crash with them (as far as i remember, CI also use ob_start() and ob_clean(), built in, in their core class, and they maybe will give you problems too). Cannot modify header information - headers already sent - El Forum - 04-30-2011 [eluser]Sudz[/eluser] Initially i send the buffer to read it contents and write zip file, and then i send the header to force download. This is what i am trying to do. Cannot modify header information - headers already sent - El Forum - 04-30-2011 [eluser]toopay[/eluser] Since CI also use ob_start() and ob_end_clean(), so that If you use those, you should provide proper validation (which i'm not see so far in your code, as i said above). And i've just notice, that you write this on helper file instead library file. I suggest you modify your helper into some Library/Class, so you can do more proper validation, or even use download helper, something like... Code: /* [NOT TESTED] */ Cannot modify header information - headers already sent - El Forum - 05-01-2011 [eluser]Sudz[/eluser] Thanks toopay, I got my mistake, I was sending to buffer output prior to sending header that's why. Thanks for your above code I converted my helper to library and it works fine. |