Page 1 of 1

problem with header

Posted: Sun Jan 11, 2004 8:11 am
by pelegk2
when i try to do :
[php_man] header ("Content-Type: text/html; charset=iso-8859-1; "); [/php_man]

i get :
Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\matav\SendFlashCommentData.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\matav\SendFlashCommentData.php on line 4
why is that?
thanks in advance
peleg

Posted: Sun Jan 11, 2004 8:13 am
by JAM
All headers needs to be sendt first in the script.
Works:

Code: Select all

<?php
 header("here");
 echo 'foo';
?>
Wont work:

Code: Select all

<?php
// space above <?php
 header("here");
 echo 'foo';
?>

Code: Select all

<?php
 echo 'foo'; // output before header
 header("here");
?>

Posted: Sun Jan 11, 2004 8:13 am
by Bennettman
You've got some HTML output before the header command. There can't be any output before headers. If you haven't got any HTML, make sure the PHP open tag is the first thing (before any content, spaces or line breaks) in the file.

Posted: Sun Jan 11, 2004 8:30 am
by pelegk2
ow ok thanks!