Page 1 of 1

Cannot modify header information - headers already sent

Posted: Mon Jun 27, 2016 5:27 pm
by itk-ra
In the shipping-module I get this message upon saving changes:
Warning: Cannot modify header information - headers already sent by (output started at /home/[user]/public_html/shop/admin/language/no-nb/shipping/weight.php:1) in /home/[user]/public_html/shop/system/library/response.php on line 12

The page is then displayed as blank.
Normal users / admin of the shop will think this is an error, allthough the changes are saved.

I have checked the language file (weight.php) does not start with a space (this would invoke this Warning), and that the response-function is free from errors. By disabling the

Code: Select all

exit();
in the function no other errors occur.

Please help me figure this out. I'm kind of stuck.

All the best :)

Re: Cannot modify header information - headers already sent

Posted: Wed Jun 29, 2016 2:13 pm
by magikcommerce
Solution 1st :
Download the file stated at the error message (i.e file admin/language/no-nb/shipping/weight.php) then apply solution bellow:

step #1. Remove spaces at beginning and end of file.

Code: Select all

<?php //contain space 
echo "remove all space or line-break before <?php and after ?>"; 
?>
step #2. Resave the file with Notepad++ or another editor (encode file as ANSI or UTF-8 without BOM).
step #3. Reupload to server through FTP in ASCII mode, not binary.

--XXX----

Solution 2nd :

step #1 Go to admin folder open index.php
step #2 write ob_start(); at beginning after <?php
step #3 write ob_end_flush(); at end before ?>
and Save file
And your code will look like:

Code: Select all

<?php
ob_start();
// code goes here
ob_end_flush();
?>

Re: Cannot modify header information - headers already sent

Posted: Wed Jun 29, 2016 7:21 pm
by straightlight
Another alternative solution would be to use the already implemented and used function of:

Code: Select all

if (!headers_sent()) {
    // Argument here.
}
However, this methodology can already be dependable by using the:

Code: Select all

$this->response->addHeader("Your header content here")
where "Your header content here" can be replaced with each lines containing your header envelope content.

Re: Cannot modify header information - headers already sent

Posted: Mon Sep 26, 2016 11:09 pm
by deshoon1
is there a resolution, i get the same error?