header function error: Warning: Cannot modify header information
Author: (---.txucom.net)
Date: 01-08-04 21:14
Hi,
I am trying to use a form for a guestbook script to store the information into a database and then once the user clicks submit, it will take them back to the entries. My problem is that when I run the script I get this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/rottedha/public_html/guestbook.php:5) in /home/rottedha/public_html/guestbook.php on line 201
Lines 200 and 201 look like this:
Line 200: $ref = $_SERVER['HTTP_REFERER'];
Line 201: header ("Location: $ref");
I can't seem to find out why this is happening. If someone could help I would greatly appreciate it.
you have shown all your code, but its most likely that you have either sent some html code to the browser (like "") or that there is a blank line above one of the "
check for both of those.
It's because you have allready sent some data to the browser before line 201, I don't know what you have sent because you only wrote those two lines, but I suggest you remove it, or put it after line 201. But since you are redirecting to another page, you could remove it anyway..
You cannot send any data before the header() function, not even or something like that.. ;)
Re: header function error: Warning: Cannot modify header information
Author: (61.1.204.---)
Date: 01-30-04 08:00
I came here thro Googling for this error...
AND WOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
thanks to Bastien, got it solved.
There was indeed a empty line right on the top.
Thanks Bastien. THanks a ton!
THe Internet survives becoz of Guys like you still logging in.