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? Quote Link to comment 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 Quote Link to comment 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" Quote Link to comment 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. Quote Link to comment 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... Quote Link to comment 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); ?> Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.