1

I'm encountering this error. and I have no idea dealing with this.

Cannot modify header information - headers already sent by (output started at /home/ben213/public_html/wp-content/themes/Bendaggers/functions.php:9) in /home/ben213/public_html/wp-includes/pluggable.php on line 934

my Functions.php file line # 9 is:

<?php if(function_exists('register_sidebar'))register_sidebar();?>

while my pluggable.php # 934 is

function wp_redirect($location, $status = 302) { global $is_IIS;

$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);

if ( !$location ) // allows the wp_redirect filter to cancel a redirect
    return false;

$location = wp_sanitize_redirect($location);

if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
    status_header($status); // This causes problems on IIS and some FastCGI setups

header("Location: $location", true, $status);}
endif;

I'm having a hard time figuring this out since im not a programmer. what seems to be wrong? kindly help me please...

Ben Daggers
  • 1,000
  • 1
  • 16
  • 51
  • possible duplicate of [Cannot modify header information - headers already sent by... Wordpress Issue](http://stackoverflow.com/questions/7381661/cannot-modify-header-information-headers-already-sent-by-wordpress-issue) – fvu Sep 11 '11 at 23:00
  • thank you Seth for the concern with regards to my "accept ratings". you we're very helpful! – Ben Daggers Sep 11 '11 at 23:15
  • @Ben, tick the answers that has helped you, for each of your previous questions. It's the little tick-mark next to the rating. The number. – KarlP Sep 12 '11 at 20:25
  • possible duplicate of [Headers already sent by PHP](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – Jocelyn Mar 25 '13 at 02:01

4 Answers4

3

I'll give 99.9% this trouble comes up because of undesirable whitespace(s) somewhere before the first "<?" and after the last "?>" in a php script. Editing saving a file in different encoding can add such whitespace too (because of BOM). So it's not always depends on your attentivness. Use Notepad2 or something to edit code and better try to use in-built on-line theme editor in the admin console. Try to find and eliminate all undesidrable whitespaces in every theme's php file and resave those files.

mishau
  • 582
  • 4
  • 11
  • That is probably the case. I don't know about PHP, but when using JSP, even newlines after directives "counts"... – KarlP Sep 12 '11 at 20:20
  • This was the solution for me. Thanks very much. In one of my class files I had an extra line after ?>, deleted and I'm back to being a magician! – kyle May 05 '14 at 21:26
2

In my pluggable.php find function wp_redirec and in that replace

header("Location: $location", true, $status);

with

echo "<meta http-equiv='refresh' content='0;url=$location' />";
Prasad Jadhav
  • 5,090
  • 16
  • 62
  • 80
1

Here's what solved the problem for me! In 'function.php' line 9' which probably looks like

 ?>

 <?php

remove the spaces so that it looks like:

 ?>
 <?php
user1961008
  • 53
  • 1
  • 8
1

I know nothing about wordpress, but I know something about http... Maybe this can help.

The error happens because you try to change a header field, although the headers have already been sent. The headers are (automatically) sent when the actual page content are written for the first time.

(The http-headers are part of the http-protocol that sends html-pages, not a part of the html file. Stuff like status codes (404,etc) encodings, etc is sent in the headers. So in order to start writing the actual page, the headers must be written first.)

It looks like the theme (?) is used too soon, or that the "redirect" plugin is activated too late...

Try to move the "register_sidebar" until after you have checked if to do a redirect.

EDIT:

From reading you other questions, I can tell that You need to learn how to program, or use another tool. Find one or two books and give it some time. PHP is a rather mashed up language, so its not really ideal to learn how to program in, but since you seems to need it, well, there you are.

Good luck.

KarlP
  • 5,149
  • 2
  • 28
  • 41
  • thank you Karl. Sad to say im not a programmer, but i know a little of html css. to be honest, i dont even understand a single damn thing in pluggable.php when you say "Try to move the "register_sidebar" until after you have checked if to do a redirect.", how am i gonna do that? – Ben Daggers Sep 11 '11 at 23:11
  • Somehow, pluggable.php is executed. And somehow, functions.php is executed BEFORE that. Try to figure out what makes it so, and change it so that the line that registers the sidebar is executed AFTER the line in pluggable.php – KarlP Sep 11 '11 at 23:23
  • 1
    But I think you are in deep waters really. If you have copied/pasted a lot of code you don't understand, then it's probably a good idea to strip that, and try to start from the beginning, with stuff you DO understand. – KarlP Sep 11 '11 at 23:26