Re: Re: One more 'Headers Already Sent' error. :-(

From: Date: Wed, 26 Jun 2002 00:02:25 +0000
Subject: Re: Re: One more 'Headers Already Sent' error. :-(
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-103856@lists.php.net to get a copy of this message
Thanks Bruce, I thought you might be on to something because I did have that in the file header.html, however, after removing all such tags so that there was only the raw html that would exist after the <body> tag, it still gives the same error. The exat error message is: "Warning: Cannot add header information - headers already sent by (output started at c:\html\demo.e-learn.net\quizd\header.html:1) in c:\html\demo.e-learn.net\quizd\login.php on line 17 " Here is the entire contents of the file header.html: ----------------------code follows----------------------------------------------------- <style> <!-- a { text-decoration: none; font-family: Arial; font-size: 10pt; font-weight: bold } a:link { color: #990000; font-family: Arial; font-size: 10pt; font-weight: bold } a:visited { color: #990000; font-family: Arial; font-size: 10pt; font-weight: bold } a:active { color: #C0C0C0; font-family: Arial; font-size: 10pt; font-weight: bold } a:hover { color: #C0C0C0; font-family: Arial; font-size: 10pt; font-weight: bold } --> </style> <table border="0" cellpadding="0" cellspacing="0" width="100%" height="75"> <tr> <td width="207" height="43"> <img border="0" src="elearn.jpg" alt="e-Learn Solutions" width="205" height="39"></td> <td width="505" height="43"></td> </tr> <tr> <td height="1" bgcolor="#990000" colspan="2"> <img src="khaki.gif" border="0" alt width="1" height="1"></td> </tr> <tr> <td width="714" colspan="2" height="1"> <p align="center"><a href="login.php">Login</a> | <a href="logout.php"> Logout</a> | View Quizzes</td> </tr> <tr> <td height="1" bgcolor="#990000" colspan="2"> <img src="khaki.gif" border="0" alt width="1" height="1"></td> </tr> <tr> <td width="714" colspan="2" height="21"></td> </tr> </table> -----------------code ends-------------------------------------------------- I did try removing the <style> tag but it had no effect. I'm just stumped. Thanks again. ...Brad "Bruce Karstedt" <bkarstedt@prodigy.net> wrote in message news:005c01c21c9e$f0d64560$e70a3941@c3... > Are you sure that both files don't have a <HEAD> </HEAD> section in them? > > Bruce Karstedt > President > Technology Consulting Associates, Ltd. > Tel: 847-735-9488 > Fax: 847-735-9474 > > > -----Original Message----- > From: Brad Melendy [mailto:brad@techknow.biz] > Sent: Tuesday, June 25, 2002 5:08 PM > To: php-general@lists.php.net > Subject: [PHP] Re: One more 'Headers Already Sent' error. :-( > Importance: Low > > > Well, I have traced this down to line 4 in the following code > 'include("header.html");' which just includes my navigation bar. If I > comment it out, everything works great, if I leave it in, I get the error > Headers Already Sent. The file it purely html. What could be the problem?? > Thanks in advance! > > <?php > error_reporting(2039); > include("dblib.inc"); > include("userlib.inc"); > include("header.html"); > $message=""; > if ( isset( $actionflag ) && $actionflag == "login" ) > { > if ( empty( $form[login] ) || empty( $form[password] ) ) > $message .= "You must fill in all fields<br>\n"; > if ( ! ( $row_array = checkPass( $form[login], $form[password] ) ) ) > $message .= "Incorrect password. Please try again<br>\n"; > if ( $message == "" ) // we found no errors > { > LastLogin($row_array[login]); > cleanSession( $row_array[id], $row_array[login], $row_array[password] ); > header( "Location: index.php?".SID ); > } > } > ?> > > > "Brad Melendy" <brad@techknow.biz> wrote in message > news:20020625200359.74200.qmail@pb1.pair.com... > > Hi All, > > I know this has come up before and I've read some posts so far, but this > is > > still eluding me. > > > > I have come to understand that typically, if you are getting an error > > message about your headers having already been sent to the browser, you > are > > writing bad code. Now, I want to right good code so I really want to > figure > > this out the right way and stay away from doing stuff like setting Output > > Buffering to ON in the php.ini file, (which I can do in my case). > > > > So, basically, I get the error message: > > > > "Warning: Cannot add header information - headers already sent by (output > > started at /home/bmelendy/websites/www.e-learn.net/quizD/header.html:3) in > > /home/bmelendy/websites/www.e-learn.net/quizD/login.php on line 17" > > > > Now, I can see right on line 17 that I'm outputting a header with the > > following line: > > > > header( "Location: index.php?".SID ); > > > > This is part of an if/then statement that is supposed to redirect the user > > to index.php upon login. The conflict occurs because I have an include > file > > with a function checkUser() that also redirects the user to the login.php > > page if they fail the the check with a line: > > > > header( "Location: /main/login.php" ); > > > > So, is there no way for me to redirect a user from both a function under > > certain circumstances and also from withing a page that calls that > function? > > I don't completely understand when exactly the headers are being sent and > > this does all work properly if I turn the Output Buffering to 'ON' in the > > php.ini file, but I'd like to try to make this work the 'right' way rather > > than cut corners and just make the server work for my code, instead of > > making my code work for the server. ;-) > > > > Thanks very much for any input. > > > > ...Brad > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#103856) next »