problem with header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

problem with header

Post 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
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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");
?>
Last edited by JAM on Sun Jan 11, 2004 8:15 am, edited 1 time in total.
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post 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.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

ow ok thanks!
Post Reply