===
Q. Why am I getting the error message 'Headers already sent'?
A. PHP produces this error message when you try to set a header for a web
page after you have already started sending out the content of the page.
Web content is always delivered with a few headers at the top, ending with a
blank line. For example, a web page might start like this:
HTTP/1.1 200 OK
Date: Tue, 01 Mar 2005 12:00:00 GMT
Content-Type: text/html
<html>
<body> ... etc...
Once you have started sending the content of a document, you can't add any
more headers because they won't appear at the top.
To get round this problem, use PHP's output control functions to buffer the
output before it is sent. For example, you can generate a "Content-Length"
header as follows:
<?php
ob_start(); // Turn on output buffering
// Create your web page/jpeg file/whatever here
echo "<html><body> ... ";
// Generate a "Content-Length" header
$clen = ob_get_length();
header("Content-Length: $clen");
// Now send the buffered content
ob_flush();
?>
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/