PDA

View Full Version : Getting past "Header already sent" errors


cinq
05-27-2005, 01:37 AM
I am trying to put this:

header("Content-type: image/png");

in a file edit so that i can display a generated thumbnail but it sends out a "header already sent" error.

Is there any way i can get past this ?
Much thanks in advance. :)

Andreas
05-27-2005, 02:26 AM
Check for blank lines before <?php, this is the most common issue.
Are you trying this within vB?
Then cookies might be an issue.

cinq
05-27-2005, 02:34 AM
Yep kirby... adding my code to functions_bbparse.php actually.

cinq
05-28-2005, 03:14 PM
anyone ? :(

Marco van Herwaarden
05-28-2005, 03:45 PM
I don't think you can send a header after the body has started. But i am not a html guru.

Trigunflame
05-28-2005, 04:25 PM
headers sent by header() are not HTML headers, they are HTTP headers which are sent in the "Header" of the HTTP reply back to the client.. ie.

your browser sends something like

GET / HTTP/1.1
Host: vbulletin.org
Connection: keep-alive

Server sends something back like

HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 5
Content-Type: text/plain

Jebus

So if you are getting that error, it means you have already outputted some sort of data, either intentionally or unintentionally..

Rule of thumb is, always output headers with header() before you ever output anything.