if any output is sent before the header statement, it won't work. from the manual:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
One thing to be careful about is to make sure that your script:
<?php
// php code
?>
has no trailing white space after the ?>
The white space gets sent and this will cause your header statement to fail.
hope this helps
r