Simple problem I think!!!!!

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....


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-05-2004
Gavin
 
Posts: n/a
Default Simple problem I think!!!!!

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.


Reply With Quote
  #2 (permalink)  
Old 09-05-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: Simple problem I think!!!!!

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



Reply With Quote
  #3 (permalink)  
Old 09-05-2004
Ike
 
Posts: n/a
Default Re: Simple problem I think!!!!!

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.
>
>



Reply With Quote
  #4 (permalink)  
Old 09-05-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: Simple problem I think!!!!!

Ike wrote:
> Please send your entire code so we can have a look!
>


Not necessary, see my reply. A simple case of RTFM.


JW



Reply With Quote
  #5 (permalink)  
Old 09-05-2004
Tom Thackrey
 
Posts: n/a
Default Re: Simple problem I think!!!!!


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)
Reply With Quote
  #6 (permalink)  
Old 09-05-2004
Andy Hassall
 
Posts: n/a
Default Re: Simple problem I think!!!!!

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
Reply With Quote
  #7 (permalink)  
Old 09-07-2004
Gavin
 
Posts: n/a
Default Re: Simple problem I think!!!!!

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
>
>
>



Reply With Quote
  #8 (permalink)  
Old 10-04-2004
morfy50
 
Posts: n/a
Default Re: Simple problem I think!!!!!

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(...)
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:04 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0