WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the wrong with this code. I am always getting the error like:

Warning: Cannot modify header information - headers already sent by (output started at /home/krishnas/Documents/wordpress/wp-admin/menu-header.php:91) in /home/krishnas/Documents/wordpress/wp-includes/pluggable.php on line 866

$upload_dir = wp_upload_dir();
        $basedir = $upload_dir['basedir'];
        $baseurl = $upload_dir['baseurl'];
        $filename = "products_".date('YmdHis').".xls";
        $fp = fopen($basedir.'/'.$filename,'wr');
        $excell_file = $baseurl.'/'.$filename;
        //echo $basedir;
        //echo $baseurl;
share|improve this question

closed as not a real question by toscho Sep 20 '12 at 23:39

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

where is this code? wp_redirect has to be used before any data is sent to the browser. – Milo Mar 18 '12 at 5:48

Make sure there is no blank space or any extra character after ?> of PHP. It's seen that such errors are usually causes by extra characters after ?> at the end of file. Please check both the files mentioned in the error code. Let us know if this resolves your error.

share|improve this answer
If ?> comes at the end of the file you can just leave it out too. – Geert Mar 18 '12 at 7:58

please review information in this WordPress codex for solving "headers already sent" warnings.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.