PHP or OS Problem<

liunx

Guest
Hi,
I have this script that I took from a tutorial and I am either getting
"The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:"

or

"Cannot modify header information - headers already sent by"...

and I get that windows xp box that says that a program has to close saying:
"PHP Script Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience."

Can anyone tell me whats wrong please? All my other PHP scripts work.
Here is the script:


<?php
// File Name: auth01.php
// Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}

// If not empty, display values for variables

else {

echo "
<P>You have entered this username: $PHP_AUTH_USER<br>
You have entered this password: $PHP_AUTH_PW<br>
The authorization type is: $PHP_AUTH_TYPE</p>
";

}

?>


Thank Youthe header rror you get is becauese you ouput before the script like:


html stuff <b>blaat</b>
<?php
// File Name: auth01.php
// Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}

// If not empty, display values for variables

else {

echo "
<P>You have entered this username: $PHP_AUTH_USER<br>
You have entered this password: $PHP_AUTH_PW<br>
The authorization type is: $PHP_AUTH_TYPE</p>
";

}

?>


just put the script at the top of your page, above all other.

the other error you get is prolbaly a program error, and has nothing to do with your phpscriptIt is on top of my page. There is nothing before this script.

?hm, do you include the file in a other file maybe ?

or do you go directly to this file ?

(when i try it on my server, it works fine)No, I didn't include it in another file. I open it directly. It works on your server? So there is something wrong with my PHP config maybe?
Anyone know what could be wrong?

ThanksOriginally posted by true_caucasi
Hi,
I have this script that I took from a tutorial and I am either getting
"The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:"

or

"Cannot modify header information - headers already sent by"...

and I get that windows xp box that says that a program has to close saying:
"PHP Script Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience."

Can anyone tell me whats wrong please? All my other PHP scripts work.
Here is the script:
Thank You
what is the exact error? I need line numbers.

that cannot be the whole script if you get the headers already sent error. the code you show will not do that as it sits.That is the whole code. There is nothing before that. Ok, now I am not getting the headers already sent. When I just went to the page, it gave me the popup to enter the password as it should. After I entered it, I get:
That windows xp box that says that a program has to close saying:
"PHP Script Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience."
After clicking "Don't send" I get:
"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:"

Anyone know?

Thank Youwhat servr are you using Apache or IIS?

it also sounds like php needs to be reinstalled. what version do you have?I am using IIS 5.1 with PHP 4.3.1
That's what I thought, but all my other scripts are working. If it was a problem with PHP then shouldnt the other scripts also not work?

Thankswell that is true, so it has to be the script. if that is the case then that can't be all the code. unless IIS is not setup properly to do WWW-AuthenticateLOL, that is all the code, I wouldn't be lying to you :confused: I am trying to get help.
Maybe thats the problem, how could I check?
By the way, the pop-up that asks for the password does come up, its just after I enter username/pass I get this.
So how can I check?

Thanksis php setup as a cgi module or ISAPI?I'm not sure, Sorry.
How do I check?put this in a file and run it.

<?php
phpinfo();
?>

and then up at teh top you should see if it is a cgi or module.Is this what you are talking about?
Server API --- CGI/FastCGIyup that is it. since it is setup as cgi then you cannot use the WWW-AuthenticateSo what can I do to fix this? Can I set it up as something other than CGI, what's the difference? And what do the majority of the hosts on the net have, do you know?

<!-- m --><a class="postlink" href="Thankshttp://www.onlamp.com/pub/a/php/2000/12/14/php_admin.html">Thankshttp://www.onlamp.com/pub/a/php/2 ... admin.html</a><!-- m -->

and hosts vary on what they have.
 
Back
Top