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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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