This is a discussion on Simple problem I think!!!!! within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I have the following code: if(mail($to,$subject,$body,$from)) { //go to Spoono Header ("Location: http://www.spoono....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have the following code:
if(mail($to,$subject,$body,$from)) { //go to Spoono Header ("Location: http://www.spoono.com/"); - Line 21 is here. } else { //else go to Yahoo Header ("Location: http://www.yahoo.com/"); } Easy Eh!!! NOOOOOOOOOOOOOOOOOOOO. I get this error ALLLLL the time, and can't work out why. Any Ideas? Warning: Cannot modify header information - headers already sent by (output started at /home/www/listerradio.com/mail.php:12) in /home/www/listerradio.com/mail.php on line 21 Thanks Gavin. |
|
|||
|
Gavin wrote:
> I get this error ALLLLL the time, and can't work out why. Any Ideas? > > Warning: Cannot modify header information - headers already sent by > (output started at /home/www/listerradio.com/mail.php:12) in > /home/www/listerradio.com/mail.php on line 21 > This is the most frequently asked question of them all. To quote the manual (http://www.php.net/header): "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." JW |
|
|||
|
Please send your entire code so we can have a look!
"Gavin" <a@b.com> wrote in message news:WAE_c.91$6m1.61@newsfe5-gui.ntli.net... > I have the following code: > > if(mail($to,$subject,$body,$from)) > { > //go to Spoono > Header ("Location: http://www.spoono.com/"); - Line 21 is here. > > } > else > { > //else go to Yahoo > Header ("Location: http://www.yahoo.com/"); > } > > Easy Eh!!! > > NOOOOOOOOOOOOOOOOOOOO. > > I get this error ALLLLL the time, and can't work out why. Any Ideas? > > Warning: Cannot modify header information - headers already sent by (output > started at /home/www/listerradio.com/mail.php:12) in > /home/www/listerradio.com/mail.php on line 21 > > Thanks > > Gavin. > > |
|
|||
|
On 5-Sep-2004, "Gavin" <a@b.com> wrote: > I have the following code: > > if(mail($to,$subject,$body,$from)) > { > //go to Spoono > Header ("Location: http://www.spoono.com/"); - Line 21 is here. > > } > else > { > //else go to Yahoo > Header ("Location: http://www.yahoo.com/"); > } > > Easy Eh!!! > > NOOOOOOOOOOOOOOOOOOOO. > > I get this error ALLLLL the time, and can't work out why. Any Ideas? > > Warning: Cannot modify header information - headers already sent by > (output > started at /home/www/listerradio.com/mail.php:12) in > /home/www/listerradio.com/mail.php on line 21 The problem is mail() is generating some output which prevents header() from working properly. Put an @ in front of the mail function call to suppress mail()'s output: if (@mail(...) -- Tom Thackrey www.creative-light.com tom (at) creative (dash) light (dot) com do NOT send email to jamesbutler@willglen.net (it's reserved for spammers) |
|
|||
|
On Sun, 05 Sep 2004 13:33:42 GMT, "Gavin" <a@b.com> wrote:
>output started at /home/www/listerradio.com/mail.php:12 Look on line 12. -- Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool |
|
|||
|
I knew it had to be simple. Thanks, all sorted now.
Gav. "Janwillem Borleffs" <jw@jwscripts.com> wrote in message news:413b1995$0$7130$abc4f4c3@news.euronet.nl... > Gavin wrote: > > I get this error ALLLLL the time, and can't work out why. Any Ideas? > > > > Warning: Cannot modify header information - headers already sent by > > (output started at /home/www/listerradio.com/mail.php:12) in > > /home/www/listerradio.com/mail.php on line 21 > > > > This is the most frequently asked question of them all. > > To quote the manual (http://www.php.net/header): > > "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." > > > JW > > > |
|
|||
|
All you have to do is use output buffering. simply call
ob_start() before anything else runs. Tom Thackrey wrote: > On 5-Sep-2004, "Gavin" <a@b.com> wrote: > > >>I have the following code: >> >>if(mail($to,$subject,$body,$from)) >>{ >> //go to Spoono >> Header ("Location: http://www.spoono.com/"); - Line 21 is here. >> >>} >>else >>{ >> //else go to Yahoo >> Header ("Location: http://www.yahoo.com/"); >>} >> >>Easy Eh!!! >> >>NOOOOOOOOOOOOOOOOOOOO. >> >>I get this error ALLLLL the time, and can't work out why. Any Ideas? >> >>Warning: Cannot modify header information - headers already sent by >>(output >>started at /home/www/listerradio.com/mail.php:12) in >>/home/www/listerradio.com/mail.php on line 21 > > > The problem is mail() is generating some output which prevents header() from > working properly. Put an @ in front of the mail function call to suppress > mail()'s output: > > if (@mail(...) > |