rhock_95 Posted March 9, 2008 Share Posted March 9, 2008 I am trying to use the following "if" statement but I get the "cannot modify header information - headers already sent........ if ($query == ""){ //echo("No results found matching your query - $query"); header('location: http://sitename.com/search.php/'); exit();} is there another way to redirect the user if the query is empty? Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/ Share on other sites More sharing options...
kenrbnsn Posted March 9, 2008 Share Posted March 9, 2008 Did you read the sticky at the top of the forum. Ken Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-487978 Share on other sites More sharing options...
rhock_95 Posted March 9, 2008 Author Share Posted March 9, 2008 my question was ..."is there another way to redirect a user using an if statement" Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-487993 Share on other sites More sharing options...
BlueSkyIS Posted March 9, 2008 Share Posted March 9, 2008 you could send a javascript or meta refresh in HTML, but you're better off fixing your header error. Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-488018 Share on other sites More sharing options...
rhock_95 Posted March 10, 2008 Author Share Posted March 10, 2008 there is no error unless I try redirect a user that submits an empty query request none of the common (see the sticky) solutions apply... Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-488140 Share on other sites More sharing options...
darkfreaks Posted March 10, 2008 Share Posted March 10, 2008 try using error_reporting <?php ini_set('error_reporting',E_ALL); ?> Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-488148 Share on other sites More sharing options...
uniflare Posted March 10, 2008 Share Posted March 10, 2008 header already sent, the only problem i have ever seen the cause of this is something echoed to the browser... JUST before the Header() function use exit(); open the source html in a text editor that shows hidden characters like newline etc (M$ Word i believe does this, as well as notepad++) you setting cookies or anything else that communicates with the browser? Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-488156 Share on other sites More sharing options...
DJTim666 Posted March 10, 2008 Share Posted March 10, 2008 Just take the simple way out. Put the following at the top of your file before ANY code. <?php ob_start('ob_gzhandler'); ?> -- DJ Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-488170 Share on other sites More sharing options...
rhock_95 Posted March 10, 2008 Author Share Posted March 10, 2008 thanks for the follow up replies It looks like an included (page) header was causing the error (I've had "('error_reporting',E_ALL); " running from the onset) regardless... it still does not redirect the page... have disturbed some other code and will try the latest suggestion as soon as I get it back together... thanks again... Link to comment https://forums.phpfreaks.com/topic/95271-problem-with-header-already-sent-error/#findComment-488179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.