Warning: Cannot modify header information - headers already sent by (output started a

boyforeigner

Well-Known Member
May 18, 2003
46
0
156
After transfer a site to a new server it started having the following problem with PHP:

Warning: Cannot modify header information - headers already sent by (output started at /home/loja/public_html/_param.php:128) in /home/loja/public_html/ljInicio.php on line 54

Anyone know how to resolve that.
 

cortices

Well-Known Member
Mar 10, 2003
45
0
156
Dallas, TX
This is actually a programming error, but a common one.

It means that the script is trying to set a header (ie. setting a cookie, redirection, etc.), but the body output has already been commited. As a header naturally must precede the body, this cannot work and results in an error.

However, there does exist a workaround for this. In your php.ini you can set the following directive:

output_buffering On

Note that this will affect your entire server.

What this does is cache the output of each PHP request until it is complete, and THEN the entire output is sent to the browser. This allows the programmer to set header information whenever he/she wishes. However, this will result in a severe performance hit on a busy server and a much better solution is to simply fix the script in question.
 

sleuth1

Well-Known Member
Mar 16, 2003
75
0
156
?> -----I have spaces here, dont ask why, you just have ! open your php editor on the said page and pull your cursor back to ?> and save, your done. ( this has been true on every occaison I have had this error, if it is not true on this occaison, let me know )