Click to See Complete Forum and Search --> : Warning: Cannot modify header information - headers already sent by


muhammad shahid
08-13-2008, 06:50 AM
hi,
i m facing an error, when this page in local host, its well , but when hosted , it gives me this error...i dont why, if on localhost in well then y not on host?
plz suggest.



Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/b/c/test1/html/modules/payment/languages/en.abc.php:42) in /home/content/a/b/c/test1/html/core_functions/functions.php on line 117

Ceox
08-13-2008, 07:19 AM
I got this exact same problem! I just get this error 3 times, it reports about lines 158, 159 and 160. On those lines is this code:


setcookie("username", "Ceox");
setcookie("password", "ceox1");
header("location: page.php");

muhammad shahid
08-13-2008, 07:24 AM
// *****************************************************************************
// Purpose redirects to other PHP page specified URL ( $url )
// Inputs $url
// Remarks this function uses header
// Returns nothing

i have these lines here :
function Redirect( $url )
{
header("Location: ".str_replace(array("\r\n",'%0d%0a',"\n",'%0a',"\r",'%0d'),'',$url));
exit;
}

creedo
08-13-2008, 07:33 AM
be sure that there is no html before you redirect the page. the error usually occurs when there is already an html sent as header to the server.

Ceox
08-13-2008, 07:44 AM
No HTML before that on my page.

muhammad shahid
08-13-2008, 09:10 AM
but how i eliminate this error.

wspeeckaert
08-13-2008, 10:13 AM
Make sure there are NO blank lines, or text of any kind before <?php

Ceox
08-13-2008, 10:32 AM
Oh shoot, I had HTML before that through an echo function!
So that has to be away from there?

SyCo
08-13-2008, 01:05 PM
// *****************************************************************************
// Purpose redirects to other PHP page specified URL ( $url )
// Inputs $url
// Remarks this function uses header
// Returns nothing

i have these lines here :
function Redirect( $url )
{
header("Location: ".str_replace(array("\r\n",'%0d%0a',"\n",'%0a',"\r",'%0d'),'',$url));
exit;
}

If this is literally your script
>i have these lines here :
needs commenting.

Please use code tags when posting code so we can see what the actual script is.

SyCo
08-13-2008, 01:08 PM
Ceox,
This error can be caused by a few things. You've kind of hijacked muhammad's thead with your version of the problem.

But in answer to your question, header info has to be the very first thing output to the page, as said no HTML, spaces or anything!

Ceox
08-14-2008, 07:17 AM
Oh sorry, didn't know that.
But thanks for the help!