Re: [PHP] Problem...header already sent by

2002-02-05 Thread Peter Ruan

Hi Jason,
  Yeap, I ran 'phpinfo()' Server API=CGI.  I look at the manual and you are
right, I must run it as Apache module.  Can someone tell me how do I change
the setting to run as an APACHE module instead?

Thanks,
-Peter

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 On Tuesday 05 February 2002 15:20, Peter wrote:
  Hi Ryan,
Thanks for the examples.  Okay, I deleted the other stuff and just put
  this code and I get this from
  my interpreter?  Is this a setting problem?


 Are you running PHP as a CGI? If so, what you want to do cannot be done.
See
 chapter HTTP authentication with PHP.


 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 You will triumph over your enemy.
 */



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




Re: [PHP] Problem...header already sent by

2002-02-05 Thread Jason Wong

On Wednesday 06 February 2002 01:52, Peter Ruan wrote:
 Hi Jason,
   Yeap, I ran 'phpinfo()' Server API=CGI.  I look at the manual and you are
 right, I must run it as Apache module.  Can someone tell me how do I change
 the setting to run as an APACHE module instead?

Well, you don't change the setting as such. On a Linux system you would've 
have to recompile PHP and possibly Apache as well. On a Windows system you 
would probably just download the relevant files and install.


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
linux: because a PC is a terrible thing to waste
([EMAIL PROTECTED] put this on Tshirts in '93)
*/

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




Re: [PHP] Problem...header already sent by

2002-02-05 Thread Peter Ruan

Ryan,
   I just tried it with my Linux box and I get the authentication 
box...which is good sign.  So it looks like a PHP in MS Windows (the 
'fabulous' windows) setting which from the error.log file indicates as well.

/** error message listed in error.log **/
[Mon Feb 04 22:36:30 2002] [error] [client 127.0.0.1] malformed header 
from script. Bad header=HTTP/1.0 401 Unauthorized: /apache/php/php.exe


In looks like a setting problem in some .ini file.  Do you know how to 
correct this problem?

Thanks for the help!
-Peter






Ryan F. Bayhonan wrote:

 It will work as expected Peter.
 
 ?php
 header (WWW-authenticate: Basic realm=\Private\);
 header (HTTP/1.0 401 Unauthorized);
 echo Unauthorized;
 exit;
 ?
 
 So where do we go from here??
 
 Ryan
 
 
 


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




Re: [PHP] Problem...header already sent by

2002-02-05 Thread Ryan F. Bayhonan

Hello again Peter,

I describe my reply below.

 I must run it as Apache module.  Can someone tell me how do I change
 the setting to run as an APACHE module instead?

I'll be replying to this question in a Windows Operating System setting. You
have 2 option in installing PHP as in Win OS, either to use the executable
installer less than 1MB file size or to use the zip file almost 4MB file
size (I recommend to use the zip file installer since its more complete
interms of modules and othre dlls).

Unzipped the zip file into any directory you want then just read and follow
the instruction found on the install.txt file. The install.txt file also
indicated how to install PHP as a module on Apache, a minor changes on the
httpd.conf must be made. The install.txt file will tell you how.

Until then

Regards,

Ryan F. Bayhonan


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




[PHP] Problem...header already sent by

2002-02-04 Thread Peter Run

Hi,
  I get the warning message (see below), whenever I try anything with
authentication/session with PHP.  This is tried under Windows (PHPTriad).  I
get the same message with my Linux drive as well.  I appreciate your help.
Please reply here and cc: to my personal email [EMAIL PROTECTED]

Thanks in advance,
-Peter
**
Warning: Cannot add header information - headers already sent by (output
started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***

1. html
2. ?php



 23.   if (!$auth) {
 24.  header(www-Authenticate: Basic realm='Private');
 25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html






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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Jeff Sheltren

You can't send anything before you send headers...  the html tag is 
messing you up I believe.

Jeff

At 08:24 PM 2/4/2002 -0800, Peter Run wrote:
Hi,
   I get the warning message (see below), whenever I try anything with
authentication/session with PHP.  This is tried under Windows (PHPTriad).  I
get the same message with my Linux drive as well.  I appreciate your help.
Please reply here and cc: to my personal email [EMAIL PROTECTED]

Thanks in advance,
-Peter
**
Warning: Cannot add header information - headers already sent by (output
started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***

1. html
2. ?php
 


  23.   if (!$auth) {
  24.  header(www-Authenticate: Basic realm='Private');
  25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html






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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Ryan F. Bayhonan

Hello Peter.

I discribe my reply below:

 **
 Warning: Cannot add header information - headers already sent by (output
 started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
 C:\apache\htdocs\proj\sports\phps\verify.php on line 26
 ***

This warning message appear when the server already send data to the client.

 1. html
 2. ?php
 


  23.   if (!$auth) {
  24.  header(www-Authenticate: Basic realm='Private');
  25.  header(HTTP/1.0 401 Unauthrized);
 ...
 ?
 /html

In the above code, the html/html tag has been sent to the client browser
already, thus when calling header function it would cause a warning telling
you that data has been rendered already.

Hope this help.

Ryan


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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Peter Ruan


I tried it w/o the html tag and I get the BAD Header message.

-Peter

From: Jeff Sheltren [EMAIL PROTECTED]
To: Peter Run [EMAIL PROTECTED],[EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by
Date: Mon, 04 Feb 2002 21:30:42 -0800

You can't send anything before you send headers...  the html tag is
messing you up I believe.

Jeff

At 08:24 PM 2/4/2002 -0800, Peter Run wrote:
Hi,
   I get the warning message (see below), whenever I try anything with
authentication/session with PHP.  This is tried under Windows (PHPTriad).  
I
get the same message with my Linux drive as well.  I appreciate your help.
Please reply here and cc: to my personal email [EMAIL PROTECTED]

Thanks in advance,
-Peter
**
Warning: Cannot add header information - headers already sent by (output
started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***

1. html
2. ?php
 


  23.   if (!$auth) {
  24.  header(www-Authenticate: Basic realm='Private');
  25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html






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






_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




RE: [PHP] Problem...header already sent by

2002-02-04 Thread Niklas Lampén

There can't be _anything_ before headers. Even a single space and/or
linebreak causes an error.


Niklas


-Original Message-
From: Peter Ruan [mailto:[EMAIL PROTECTED]] 
Sent: 5. helmikuuta 2002 7:42
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by



I tried it w/o the html tag and I get the BAD Header message.

-Peter

From: Jeff Sheltren [EMAIL PROTECTED]
To: Peter Run [EMAIL PROTECTED],[EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by
Date: Mon, 04 Feb 2002 21:30:42 -0800

You can't send anything before you send headers...  the html tag is 
messing you up I believe.

Jeff

At 08:24 PM 2/4/2002 -0800, Peter Run wrote:
Hi,
   I get the warning message (see below), whenever I try anything with

authentication/session with PHP.  This is tried under Windows
(PHPTriad).
I
get the same message with my Linux drive as well.  I appreciate your
help.
Please reply here and cc: to my personal email [EMAIL PROTECTED]

Thanks in advance,
-Peter
**
Warning: Cannot add header information - headers already sent by 
(output started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in 
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***

1. html
2. ?php
 


  23.   if (!$auth) {
  24.  header(www-Authenticate: Basic realm='Private');
  25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html






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






_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




RE: [PHP] Problem...header already sent by

2002-02-04 Thread Martin Towell

you have :
24.  header(www-Authenticate: Basic realm='Private');
25.  header(HTTP/1.0 401 Unauthrized);

I have (and this works)

  Header (WWW-authenticate: Basic realm=\$blah\);
  Header (HTTP/1.0 401 Unauthorized);

* Unauthrized should be Unauthorized - missing o


-Original Message-
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 05, 2002 4:51 PM
To: Php-General
Subject: RE: [PHP] Problem...header already sent by


There can't be _anything_ before headers. Even a single space and/or
linebreak causes an error.


Niklas


-Original Message-
From: Peter Ruan [mailto:[EMAIL PROTECTED]] 
Sent: 5. helmikuuta 2002 7:42
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by



I tried it w/o the html tag and I get the BAD Header message.

-Peter

From: Jeff Sheltren [EMAIL PROTECTED]
To: Peter Run [EMAIL PROTECTED],[EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by
Date: Mon, 04 Feb 2002 21:30:42 -0800

You can't send anything before you send headers...  the html tag is 
messing you up I believe.

Jeff

At 08:24 PM 2/4/2002 -0800, Peter Run wrote:
Hi,
   I get the warning message (see below), whenever I try anything with

authentication/session with PHP.  This is tried under Windows
(PHPTriad).
I
get the same message with my Linux drive as well.  I appreciate your
help.
Please reply here and cc: to my personal email [EMAIL PROTECTED]

Thanks in advance,
-Peter
**
Warning: Cannot add header information - headers already sent by 
(output started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in 
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***

1. html
2. ?php
 


  23.   if (!$auth) {
  24.  header(www-Authenticate: Basic realm='Private');
  25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html






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






_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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



Re: [PHP] Problem...header already sent by

2002-02-04 Thread Peter

Hi Ryan,
  I tried and took the html/html tags out and I still get the same
messaage.  Why?

Thanks,
Peter


 Hello Peter.

 I discribe my reply below:

  **
  Warning: Cannot add header information - headers already sent by (output
  started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
  C:\apache\htdocs\proj\sports\phps\verify.php on line 26
  ***

 This warning message appear when the server already send data to the
client.

  1. html
  2. ?php
  
 
 
   23.   if (!$auth) {
   24.  header(www-Authenticate: Basic realm='Private');
   25.  header(HTTP/1.0 401 Unauthrized);
  ...
  ?
  /html

 In the above code, the html/html tag has been sent to the client
browser
 already, thus when calling header function it would cause a warning
telling
 you that data has been rendered already.

 Hope this help.

 Ryan



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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Peter Run

Okay, I deleted the other stuff and just put this code and I get this from
my interpreter?  Is this a setting problem?

Thanks,
Peter

?php
Header (WWW-authenticate: Basic realm=\Private\);
Header (HTTP/1.0 401 Unauthorized);
echo Unauthorized;
exit;
?

[Mon Feb 04 22:36:30 2002] [error] [client 127.0.0.1] malformed header from
script. Bad header=HTTP/1.0 401 Unauthorized: /apache/php/php.exe

Martin Towell [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
you have :
24.  header(www-Authenticate: Basic realm='Private');
25.  header(HTTP/1.0 401 Unauthrized);

I have (and this works)

  Header (WWW-authenticate: Basic realm=\$blah\);
  Header (HTTP/1.0 401 Unauthorized);

* Unauthrized should be Unauthorized - missing o


-Original Message-
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 05, 2002 4:51 PM
To: Php-General
Subject: RE: [PHP] Problem...header already sent by


There can't be _anything_ before headers. Even a single space and/or
linebreak causes an error.


Niklas


-Original Message-
From: Peter Ruan [mailto:[EMAIL PROTECTED]]
Sent: 5. helmikuuta 2002 7:42
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by



I tried it w/o the html tag and I get the BAD Header message.

-Peter

From: Jeff Sheltren [EMAIL PROTECTED]
To: Peter Run [EMAIL PROTECTED],[EMAIL PROTECTED]
Subject: Re: [PHP] Problem...header already sent by
Date: Mon, 04 Feb 2002 21:30:42 -0800

You can't send anything before you send headers...  the html tag is
messing you up I believe.

Jeff

At 08:24 PM 2/4/2002 -0800, Peter Run wrote:
Hi,
   I get the warning message (see below), whenever I try anything with

authentication/session with PHP.  This is tried under Windows
(PHPTriad).
I
get the same message with my Linux drive as well.  I appreciate your
help.
Please reply here and cc: to my personal email [EMAIL PROTECTED]

Thanks in advance,
-Peter
**
Warning: Cannot add header information - headers already sent by
(output started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***

1. html
2. ?php
 


  23.   if (!$auth) {
  24.  header(www-Authenticate: Basic realm='Private');
  25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html






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






_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Peter Ruan

Okay, I deleted the other stuff and just put this code and I get this from
my interpreter?  Is this a setting problem?

Thanks,
Peter

Niklas lampén [EMAIL PROTECTED] wrote in message
007701c1ae09$1bde80b0$ba93c5c3@Niklas">news:007701c1ae09$1bde80b0$ba93c5c3@Niklas...
 There can't be _anything_ before headers. Even a single space and/or
 linebreak causes an error.


 Niklas


 -Original Message-
 From: Peter Ruan [mailto:[EMAIL PROTECTED]]
 Sent: 5. helmikuuta 2002 7:42
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP] Problem...header already sent by



 I tried it w/o the html tag and I get the BAD Header message.

 -Peter

 From: Jeff Sheltren [EMAIL PROTECTED]
 To: Peter Run [EMAIL PROTECTED],[EMAIL PROTECTED]
 Subject: Re: [PHP] Problem...header already sent by
 Date: Mon, 04 Feb 2002 21:30:42 -0800
 
 You can't send anything before you send headers...  the html tag is
 messing you up I believe.
 
 Jeff
 
 At 08:24 PM 2/4/2002 -0800, Peter Run wrote:
 Hi,
I get the warning message (see below), whenever I try anything with

 authentication/session with PHP.  This is tried under Windows
 (PHPTriad).
 I
 get the same message with my Linux drive as well.  I appreciate your
 help.
 Please reply here and cc: to my personal email [EMAIL PROTECTED]
 
 Thanks in advance,
 -Peter
 **
 Warning: Cannot add header information - headers already sent by
 (output started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
 C:\apache\htdocs\proj\sports\phps\verify.php on line 26
 ***
 
 1. html
 2. ?php
  
 
 
   23.   if (!$auth) {
   24.  header(www-Authenticate: Basic realm='Private');
   25.  header(HTTP/1.0 401 Unauthrized);
 ...
 ?
 /html
 
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 




 _
 Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Peter Ruan

Okay, I deleted the other stuff and just put this code and I get this from
my interpreter?  Is this a setting problem?

Thanks,
Peter

?php
Header (WWW-authenticate: Basic realm=\Private\);
Header (HTTP/1.0 401 Unauthorized);
echo Unauthorized;
exit;
?

[Mon Feb 04 22:36:30 2002] [error] [client 127.0.0.1] malformed header from
script. Bad header=HTTP/1.0 401 Unauthorized: /apache/php/php.exe

Niklas lampén [EMAIL PROTECTED] wrote in message
007701c1ae09$1bde80b0$ba93c5c3@Niklas">news:007701c1ae09$1bde80b0$ba93c5c3@Niklas...
 There can't be _anything_ before headers. Even a single space and/or
 linebreak causes an error.


 Niklas




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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Ryan F. Bayhonan

Hello Peter. Good Day.

Omitting html/html does not solve the problem. I've experience this
problem also before. I found out that the once causing the problem is when
any data that has been sent to the client. I have listed some example below.

Examples: All of these will cause a warning when header is called.

1. Since the tag html will be interpreted by the client browser first
before the ?php ... ? tags, data has been sent to the client, telling the
client that an html file is being rendered. So when the browser interprets
the header function, a warning will be issued.

html
?php
header( some parameters );
exit;
 ?

2. This will also cause an error. Remember that a call to an echo or print
function will send data (the parameters of the function) to the client. So
when the header is interpreted, a warning will be issued.

?php
echo Some text;
header( some params );
exit;
?

Hope this is clear to you now. When a data has been sent already to the
client, a call to a header will fail. The best thing you must do is to put
the logic/check part on the first line of the file (See below). In the
example below, I check first is the a user is valid by calling the the
function verify_user( params... ) before any other html tags be rendered. So
when the user is not valid it will redirect an error page, if it is valid,
the Welcome to page will be printed.

?php
 session_start();
 include 'include/config.inc';
 include 'include/pgsql.inc';

 if (!verify_user($username, $Password, $c_id))
 {
  session_register(isValid);
  $isValid=false;
  $title = Web-based Training System Login;
  $msg = Access Denied!!!;
  $link = ../../index.php?id=.$c_id;
  header(Location:
notify2.php?title=.urlencode($title).msg=.urlencode($msg).link=.urlen
code($link));
  exit;
 }
?
html
body
Welcome to the page.
/body
/html

Hope this help you more.

Until then...

Ryan F. Bayhonan

- Original Message -
From: Peter [EMAIL PROTECTED]
To: Ryan F. Bayhonan [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, February 05, 2002 2:14 PM
Subject: Re: [PHP] Problem...header already sent by


 Hi Ryan,
   I tried and took the html/html tags out and I still get the same
 messaage.  Why?

 Thanks,
 Peter


  Hello Peter.
 
  I discribe my reply below:
 
   **
   Warning: Cannot add header information - headers already sent by
(output
   started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
   C:\apache\htdocs\proj\sports\phps\verify.php on line 26
   ***
 
  This warning message appear when the server already send data to the
 client.
 
   1. html
   2. ?php
   
  
  
23.   if (!$auth) {
24.  header(www-Authenticate: Basic realm='Private');
25.  header(HTTP/1.0 401 Unauthrized);
   ...
   ?
   /html
 
  In the above code, the html/html tag has been sent to the client
 browser
  already, thus when calling header function it would cause a warning
 telling
  you that data has been rendered already.
 
  Hope this help.
 
  Ryan
 
 

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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Peter

Hi Ryan,
  Thanks for the examples.  Okay, I deleted the other stuff and just put
this code and I get this from
my interpreter?  Is this a setting problem?

Thanks,
Peter

?php
header (WWW-authenticate: Basic realm=\Private\);
header (HTTP/1.0 401 Unauthorized);
echo Unauthorized;
exit;
?
*
/* error message from the web server */
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, [EMAIL PROTECTED] and inform them of
the time the error occurred, and anything you might have done that may have
caused the error.

More information about this error may be available in the server error log.

/* snipet from apache/logs/error.log */

[Mon Feb 04 22:36:30 2002] [error] [client 127.0.0.1] malformed header from
script. Bad header=HTTP/1.0 401 Unauthorized: /apache/php/php.exe




 Hello Peter. Good Day.

 Omitting html/html does not solve the problem. I've experience this
 problem also before. I found out that the once causing the problem is when
 any data that has been sent to the client. I have listed some example
below.

 Examples: All of these will cause a warning when header is called.

 1. Since the tag html will be interpreted by the client browser first
 before the ?php ... ? tags, data has been sent to the client, telling
the
 client that an html file is being rendered. So when the browser interprets
 the header function, a warning will be issued.

 html
 ?php
 header( some parameters );
 exit;
  ?

 2. This will also cause an error. Remember that a call to an echo or print
 function will send data (the parameters of the function) to the client. So
 when the header is interpreted, a warning will be issued.

 ?php
 echo Some text;
 header( some params );
 exit;
 ?

 Hope this is clear to you now. When a data has been sent already to the
 client, a call to a header will fail. The best thing you must do is to put
 the logic/check part on the first line of the file (See below). In the
 example below, I check first is the a user is valid by calling the the
 function verify_user( params... ) before any other html tags be rendered.
So
 when the user is not valid it will redirect an error page, if it is valid,
 the Welcome to page will be printed.

 ?php
  session_start();
  include 'include/config.inc';
  include 'include/pgsql.inc';

  if (!verify_user($username, $Password, $c_id))
  {
   session_register(isValid);
   $isValid=false;
   $title = Web-based Training System Login;
   $msg = Access Denied!!!;
   $link = ../../index.php?id=.$c_id;
   header(Location:

notify2.php?title=.urlencode($title).msg=.urlencode($msg).link=.urlen
 code($link));
   exit;
  }
 ?
 html
 body
 Welcome to the page.
 /body
 /html

 Hope this help you more.

 Until then...

 Ryan F. Bayhonan

 - Original Message -
 From: Peter [EMAIL PROTECTED]
 To: Ryan F. Bayhonan [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Tuesday, February 05, 2002 2:14 PM
 Subject: Re: [PHP] Problem...header already sent by


  Hi Ryan,
I tried and took the html/html tags out and I still get the same
  messaage.  Why?
 
  Thanks,
  Peter
 
 
   Hello Peter.
  
   I discribe my reply below:
  
**
Warning: Cannot add header information - headers already sent by
 (output
started at C:\apache\htdocs\proj\sports\phps\verify.php:2) in
C:\apache\htdocs\proj\sports\phps\verify.php on line 26
***
  
   This warning message appear when the server already send data to the
  client.
  
1. html
2. ?php

   
   
 23.   if (!$auth) {
 24.  header(www-Authenticate: Basic realm='Private');
 25.  header(HTTP/1.0 401 Unauthrized);
...
?
/html
  
   In the above code, the html/html tag has been sent to the client
  browser
   already, thus when calling header function it would cause a warning
  telling
   you that data has been rendered already.
  
   Hope this help.
  
   Ryan
  
  
 
  --
  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




Re: [PHP] Problem...header already sent by

2002-02-04 Thread Ryan F. Bayhonan

It will work as expected Peter.

?php
header (WWW-authenticate: Basic realm=\Private\);
header (HTTP/1.0 401 Unauthorized);
echo Unauthorized;
exit;
?

So where do we go from here??

Ryan



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