Jump to content

problem with "header already sent" error


rhock_95

Recommended Posts

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

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?

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.