Re: [PHP] Newbie error with cookies and headers already declared

2004-05-21 Thread Stephen Lake
All headers have to be sent before any output is sent to the browser.

"Chris W. Parker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
GodFoca 
on Friday, May 21, 2004 1:29 PM said:

> Warning: Cannot add header information - headers already sent by
> (output started at /home/tiempodemaria/main.php:3) in
> /home/tiempodemaria/main.php on line 11

[snip]

> Does anybody knows what's going on? I don't understand which header
> is being sent before the setting of the cookie, and I don't
> understand the ":3" in the error description. This page is a frame,
> so I don't have any head tag, does that matter to php?

headers != 

it's basically this:

1. you cannot create/write a cookie after you send any html output to
the client.
2. you cannot create/write a session value after you send any html
output to the client.

for one, you've got  at the very top of main.php. try rearranging
your file like this:







...



hope this helps,
chris.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Newbie error with cookies and headers already declared

2004-05-21 Thread Chris W. Parker
GodFoca 
on Friday, May 21, 2004 1:29 PM said:

> Warning: Cannot add header information - headers already sent by
> (output started at /home/tiempodemaria/main.php:3) in
> /home/tiempodemaria/main.php on line 11

[snip]

> Does anybody knows what's going on? I don't understand which header
> is being sent before the setting of the cookie, and I don't
> understand the ":3" in the error description. This page is a frame,
> so I don't have any head tag, does that matter to php?

headers != 

it's basically this:

1. you cannot create/write a cookie after you send any html output to
the client.
2. you cannot create/write a session value after you send any html
output to the client.

for one, you've got  at the very top of main.php. try rearranging
your file like this:







...



hope this helps,
chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie error with cookies and headers already declared

2004-05-21 Thread Daniel Clark
Try putting your  below setting the cookie.

> I'm getting this error:
>
> Warning: Cannot add header information - headers already sent by (output
> started at /home/tiempodemaria/main.php:3) in /home/tiempodemaria/main.php
> on line 11
>
> With this code in "main.php":
>
> 
>   define(SECONDS_IN_THREE_MONTHS, 3600*24*90);
>  define(OFFSET_WITH_GMT, -3*3600);
>
>  $has_visited = isset($_COOKIE["TdM_visited"]);
>
>  if (!$has_visited) {
>   setcookie("TdM_visited",
>   (string) (time() + OFFSET_WITH_GMT),
>   time() + OFFSET_WITH_GMT + SECONDS_IN_THREE_MONTHS);
>
>   // the above (not blank) is line 11
>
>  } else {
>   $latestVisit = (int) $_COOKIE["TdM_visited"];
>   setcookie("TdM_visited",
>   (string) (time() + OFFSET_WITH_GMT),
>   time() + OFFSET_WITH_GMT + SECONDS_IN_THREE_MONTHS);
>  }
> ?>
> 
> 
>
> 
> .
>
> Does anybody knows what's going on? I don't understand which header is
> being
> sent before the setting of the cookie, and I don't understand the ":3" in
> the error description. This page is a frame, so I don't have any head tag,
> does that matter to php?
>
> Thanks in advance,
> Nicolas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie error with cookies and headers already declared

2004-05-21 Thread Kevin Murphy
I'm a newbie to PHP too, but
I think its the HTML tag. Move it down below the PHP and see what 
happens.

--
Kevin Murphy
Web Designer - Stubborn Donkey Productions
www.stubborndonkey.com
On May 21, 2004, at 1:28 PM, GodFoca wrote:
I'm getting this error:
Warning: Cannot add header information - headers already sent by 
(output
started at /home/tiempodemaria/main.php:3) in 
/home/tiempodemaria/main.php
on line 11

With this code in "main.php":


 $has_visited = isset($_COOKIE["TdM_visited"]);
 if (!$has_visited) {
  setcookie("TdM_visited",
  (string) (time() + OFFSET_WITH_GMT),
  time() + OFFSET_WITH_GMT + SECONDS_IN_THREE_MONTHS);
  // the above (not blank) is line 11
 } else {
  $latestVisit = (int) $_COOKIE["TdM_visited"];
  setcookie("TdM_visited",
  (string) (time() + OFFSET_WITH_GMT),
  time() + OFFSET_WITH_GMT + SECONDS_IN_THREE_MONTHS);
 }
?>




.
Does anybody knows what's going on? I don't understand which header is 
being
sent before the setting of the cookie, and I don't understand the ":3" 
in
the error description. This page is a frame, so I don't have any head 
tag,
does that matter to php?

Thanks in advance,
Nicolas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie error with cookies and headers already declared

2004-05-21 Thread GodFoca
I'm getting this error:

Warning: Cannot add header information - headers already sent by (output
started at /home/tiempodemaria/main.php:3) in /home/tiempodemaria/main.php
on line 11

With this code in "main.php":







.

Does anybody knows what's going on? I don't understand which header is being
sent before the setting of the cookie, and I don't understand the ":3" in
the error description. This page is a frame, so I don't have any head tag,
does that matter to php?

Thanks in advance,
Nicolas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php