RE: [PHP] headers already sent and cookie problem

From: Date: Wed, 16 Jul 2003 09:21:27 +0000
Subject: RE: [PHP] headers already sent and cookie problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-155378@lists.php.net to get a copy of this message
Thanks for your tips Mike! One nasty thing to debug is that the error only shows up from time to time. So now everything seems OK. What do i have now? I start my code with session_start Then include some files. The last one is get_cartID.php (remember?) Then i use several functions to have cart functionallity. In show_cart i include my page heading and then output further body and footer content. When I put the get_cartID include file AFTER include "heading.php" into my show cart function, the other functions start complaining they can't access the function get_cartID. Lots of text, sorry for that. But I still don't have the clue. Maybe you like to see my code? Any help welcome! Fred -----Original Message----- From: Ford, Mike [LSS] [mailto:M.Ford@lmu.ac.uk] Sent: dinsdag 15 juli 2003 11:36 To: 'frederik feys'; php-general@lists.php.net Subject: RE: [PHP] headers already sent and cookie problem > -----Original Message----- > From: frederik feys [mailto:frederikfeys@pandora.be] > Sent: 15 July 2003 09:45 > > This is what i get: > "Warning: Cannot add header information - headers already > sent by (output started at /home/u/r/html/store/cart.php:188) > in /home/u/r/html/store/includes/functions/get_cartID.php on line 14" This says that on line 188 of store/cart.php you started outputting your HTML page, but you can't do that before the attempt to send headers on line 14 of store/includes/functions/get_cartID.php. Take a good look at line 188 of store/cart.php to see what you can do so that it is not starting HTML output, or move the header calls above the point where it is included/required. > I know that the problem is the reading of the cookie and then > after some sripting outputting page HTML. No, other way around. > I started my code > ob_start() > and do an ob_flush() within a function(show_cart) (?might > that be a problem?) Actually, that should be a preventer for the problem, so long as the ob_start() is executed before output is started -- perhaps your ob_start() should occur earlier in your script? Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#155378) next »