Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error "Warning: cannot modify header...."

Status
Not open for further replies.

overflo

Technical User
Feb 10, 2003
70
AU
I have a dynamic website written on a comp running PHP 5 (and had also run on testing server running the same). I have uploaded to server which is running PHP 4.4.1.
The problem is I have some scripts that redirect after deleting and everything was running fine until I uploaded to server. Now I keep getting the error "Warning: Cannot modify header information - headers already sent by (output started at /home/landcare/public_html/functions_main.php:54) in /home/landcare/public_html/functions_delete.php on line 123
"
I have checked for whitespace before and after the php tags but there is none. Any suggestions would be greatly appreciated.
 
Look in functions_main.php at around line 54. The error suggests to me that you are indeed outputting something to the page (maybe an echo?) before you are attempting to send a header. Check you have no whitespace before the initial opening <? on your page that is erroring (and any includes you have on that page).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
There is definitely no whitespace. It works fine on my computer and on testing server both running php5 but not on server running 4.4.1. Could this be the problem ?
 
Your functions_main could be calling a php5 specific function which would output an error in the previous versions. Outputed error would count as an output.
 
hmmm bummer coz theres a quite a few functions. Thanks for your help, I better get on it coz it's s'posed to be all up and running in 4 hours time :)
 
It's allowing the header("Location: $url") redirect when I'm adding to the database, but it comes up with the error only when I'm deleting.
 
So step through your debug process, and find out what might output an error or warning or some type of echo statement.

I'll give you a hint, it's on line 54 of functions_main.php ;)
 
No. solved it. it just needed
ob_start();
I'd somehow overlooked it.

Thanks for all the replies.
 
ob_start() just buffers all the output... it doesn't mean you're not throwing any errors or warnings.

It's certainly one way to it, but it may be masking a bigger issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top