I'm having problems with a php script I'm working on. A few weeks ago I posted a question, and received a nice code snippet. I modifed the snippet, and tried running it locally and got an Internal Server Error... The funny thing is it works fine on my site. This has me baffled...

Apache's errorlog says:
[Fri Sep 27 21:10:55 2002] [error] [client 127.0.0.1] malformed header from script. Bad header=HTTP/1.0 401 Unauthorized: c:/php/php.exe
Heres the code:
PHP Code:
<?php

function authenticate() {
    
header"WWW-Authenticate: Basic realm=\"CCServ Admin\"");
    
header"HTTP/1.0 401 Unauthorized");
    echo 
"<p><b>Error 401: Unauthorized</b></p>";
    exit;
}

if (!isset(
$_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
    
authenticate();
} else {
        require_once(
"config.inc.php");
        require_once(
"includes/sql_layer.php");
        
$dbi sql_connect($dbhost$dbuname$dbpass$dbname);

        
$result sql_query("SELECT * FROM `admin` WHERE username='$xuser'"$dbi);
        if (!
result) {
                echo 
"<title>CC Server Admin - Login Failure</title>\n";
                echo 
"Invalid Login";
                return;
        } else {
                list(
$username$pw ) = sql_fetch_row($result$dbi);
        }

        if (
$xuser == $username and $pw==$pass) {
                echo 
"<title>CC Server Admin</title>\n";
                echo 
"Access Granted";
        } else {
                echo 
"<title>CC Server Admin - Login Failure</title>\n";
                echo 
"Invalid Login";
                return;
        }
}

?>
I'm sure this is an apache issue because it works fine on my server, but the same code don't work on my local testing site... I'm hoping someone can shed some light on this problem.

Thanks in advance