tmyonline Posted February 17, 2008 Share Posted February 17, 2008 Guys: I'm having a problem with php header() function. It complains that Warning: Cannot modify header information - headers already sent by (output started at localhost\index.php:28) in localhost\index.php on line 85. How should I resolve to make it work ? Thanks. Link to comment https://forums.phpfreaks.com/topic/91603-problems-with-php-header-function/ Share on other sites More sharing options...
soycharliente Posted February 18, 2008 Share Posted February 18, 2008 You've probably tried to write something to the screen already. That is the most common error. Code helps. It's IMPOSSIBLE to know for sure without seeing what you're talking about. Link to comment https://forums.phpfreaks.com/topic/91603-problems-with-php-header-function/#findComment-469217 Share on other sites More sharing options...
tmyonline Posted February 18, 2008 Author Share Posted February 18, 2008 Yeah, I know that the header() function requires that nothing be allowed to output to the browser before it. However, if I move my header() function to the top of my code, things don't make sense because the criteria that result in using the header() function are not known yet. For example, I need to use the header() function to re-direct the page (actually to reload itself) if users enter invalid values at the form. But, I don't know ahead of time whether they will enter invalid values. If I put the header() at the top of my code, I will not be able to check or detect this kind of thing. However, if I put it in the bottom, then it complains,... Link to comment https://forums.phpfreaks.com/topic/91603-problems-with-php-header-function/#findComment-469234 Share on other sites More sharing options...
Guest Posted February 18, 2008 Share Posted February 18, 2008 You still need to show us some code, maybe from the start of the document to the point where the header() is executed (in its original position). Without anything else to go on, try looking for: a single space or newline before your <?php opening tag. Otherwise, is this file being included/required by another php script when its being run? If so, the including script might be printing output before your header script is run. Or maybe it might have the elusive whitespace before the <?php opening tag? Link to comment https://forums.phpfreaks.com/topic/91603-problems-with-php-header-function/#findComment-469239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.