1

I use php-export-data class for excel output. This class works on my localhost and godady server but on my new server in doesn't work.

It gives a header error. Likes this.:

Warning: Cannot modify header information - headers already sent by (output started at /home/mmm/public_html/head/adminsss/config.php:1) in /home/mmm/public_html/head/adminss/modules/head/class/php-export-data.class.php on line 489    
 Warning: Cannot modify header information - headers already sent by (output started at /home/mmm/public_html/head/adminsss/config.php:1) in /home/mmm/public_html/head/adminsss/modules/head/class/php-export-data.class.php on line 490<br>
Line 489 => header("Content-Type: application/vnd.ms-excel; charset=" . $this->encoding); 
Line 490 => header("Content-Disposition: inline; filename=\"" . basename($this->filename) . "\"");
  • localhost PHP Version 5.5.11
  • godady PHP Version 5.3.24
  • new server PHP Version 5.5.23

How can I fix this?

J. Chomel
  • 8,193
  • 15
  • 41
  • 69

1 Answers1

0

If the error message shows first line like this " /config.php:1 " , you must convert php file to be without BOM .

UTF-8 BOM

Linebreaks and spaces alone can be a problem. But there are also "invisible" character sequences which can cause this. Most famously the UTF-8 BOM (Byte-Order-Mark) which isn't displayed by most text editors. It's the byte sequence EF BB BF, which is optional and redundant for UTF-8 encoded documents. PHP however has to treat it as raw output. It may show up as the characters  in the output (if the client interprets the document as Latin-1) or similar "garbage".