All:
I have an application that has been working well for 3-4 months now
without any issues (that I am aware of). A day or two ago, one of our
employees that use this application called to say she was getting a
weird message:
"Warning: Cannot modify header information - headers already sent by
(output started at /www/htdocs/sys36/viewhist.php:2) in
/www/htdocs/sys36/viewhist.php on line 5"
I have been looking into the problem and apparently, the problem is due
to authentication. Going to other parts of the site will trigger a
prompt for username/password and once that is entered, all is well,
even with the page above.
The puzzle is that all pages using Auth use the *EXACT SAME CODE*:
if (!isset($PHP_AUTH_USER)) {
// if empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {
// if non-empty, check the database for matches
// Connect to the database
$db = mysql_connect("host", "user", "password");
mysql_select_db("sys36",$db);
$sql="SELECT * FROM Auth WHERE userid='$PHP_AUTH_USER' and
password='$PHP_AUTH_PW'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$myrow = mysql_fetch_array($result);
$userlevel=$myrow["level"];
if ($num != "0") {
} else {
$userlevel="3";
}
}
Can anyone shed any light on this?
Thanks!
rk