RE: [PHP] redirect with header() after headers sent

From: Date: Wed, 30 Aug 2000 05:01:43 +0000
Subject: RE: [PHP] redirect with header() after headers sent
Groups: php.general 
Request: Send a blank email to php-general+get-14307@lists.php.net to get a copy of this message
> The problem with this is that because the headers have gone out with the > template I prepend to each page I cannot just issue a header() call > without getting an error message about 'headers already sent in line blah > blah blah.) My first thought was to close the document by echoing an > </HTML> tag then do the redirect via header() but this did not work > either. This is sort of why they're called "header"s instead of "footer"s ;) > How can I handle this situation? I would really prefer not to display the > sql errors on the page that I was building because it's hard to tell > where in the page the sql error might interrupt the html. The result > could be a page with the banner and background color but without text! > Not very user friendly when an error occurs. > > Any thoughts / suggestions / help would be appreciated. The way I create a PHP-based site is to have the pages create their content and then at the very end of the page include the standard page menu template, then the actual contents and the standard page footer. This way you can send a Header() at any time, or set a cookie whenver you want/need to. You might want to consider doing it this way. The problem with your current set up is, once the SQL error occurs, the page is halfway on its way to the browser, and you can't stop that. Jason

« previous php.general (#14307) next »