Solved

Cannot modify header information - headers already sent by - Studio Press theme

Posted on 2014-03-06
33
426 Views
Last Modified: 2014-03-19
I keep getting this message
Cannot modify header information - headers already sent by (output started at /home/thefruga/public_html/wordpress/wp-content/themes/genesis/lib/structure/header.php:48)

I have looked at that line of code and this is what is there

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />

Open in new window


line 48 starts with <html

I am using a plugin called Shortcode Exec PHP for a require statement and to call a php function on the page that is working fine and you can see on the bottom right under Frugal Forum Topics.

Please help me get rid of this warning message.

Thanks,

Randal

my site is http://www.thefrugallife.com/wordpress/
0
Comment
Question by:sharingsunshine
  • 15
  • 15
  • 3
33 Comments
 
LVL 58

Expert Comment

by:Gary
Comment Utility
What is here? This is where new headers are trying to be set.
 /home/thefruga/public_html/smf/Sources/bad-behavior/bad-behavior/screener.inc.php on line 8
0
 

Author Comment

by:sharingsunshine
Comment Utility
function bb2_screener_cookie($bb_settings, $package, $cookie_name, $cookie_value)
{
	// FIXME: Set the real cookie
	setcookie($cookie_name, $cookie_value, 0, bb2_relative_path());
}

Open in new window


line 8 starts with setcookie

This is a spam stopper on the forum which has been installed for 5 years and no recent updates on the forum or the spam stopper program.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Please see http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

Look for the part about HTTP Headers Must Come First, Period.  PHP setcookie() issues a header command.  There is browser output occurring before the header and that is prohibited by the HTTP protocol.

Either the logic of the scripts has to change to avoid sending browser output before the cookie or you may be able to get around this by using output buffering.
0
 

Author Comment

by:sharingsunshine
Comment Utility
I have read your article but I can't say I know anymore.  As my question stated, I need help with troubleshooting this issue.  This site has ran great until I tried to require a php file within WordPress.  So if you can help me to know what to look for or how to implement output buffering that would  be helpful.

The error message seems to indicate a certain line is causing the problem please tell me what to look for.

I am not a PHP programmer but I can find my way around it and make some changes to the code.

Thanks,
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
First question: Can you roll back the changes to get the site back to working correctly?  If so, let's do that, then move on to the diagnostic steps.

When we start the diagnostic part of things, we will need to know where you got the changes you want to add to the site and how you "vetted" them for functionality and dependability.  It will be helpful to have "before" and "after" versions of the scripts in question.

How comfortable are you modifying WordPress? For example, if I told you that you needed a child theme would you immediately know what I was talking about?
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
What version of Bad Behaviour are you using?
If not 2.2.10 then upgrade.
0
 

Author Comment

by:sharingsunshine
Comment Utility
I  appreciate your interest in helping me troubleshoot this issue. I now have it back to where it needs to be like in the beginning.

Yes, I understand child theme I am using Eleven40 Pro by studiopress as the child and Genesis as the parent.

I am running SMF 2.0.7 and the latest  version of Bad Behavior for my forum is 1.5.18 and I am running 1.5.7.  The mod hasn't been updated completely to my forum so I am checking into upgrading to 1.5.17 instead.

The new functionality is via plugins and following the SMF guidelines for SSI.php to be implemented.

I don't understand what you mean by this statement:

It will be helpful to have "before" and "after" versions of the scripts in question.

Thanks,

Randal
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Bad Behaviou v1.5.18 is a very 'old' version, the current is 2.2.10 - and your problem was stemming from this plugin
You are running into conflicts between plugins and/or WP  - what version of WP are you running?
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
I'm with Gary on the version-related issues.  PHP is a living language and the frequent changes in PHP, not to mention the applications built on top of it, can cause old software to fail.  My recommendation would be to back up the existing system and install new versions of the software at the current levels.  If your site is hosted at a professional hosting company, they should already have PHP and MySQL at the right levels.  Check phpinfo() to be sure.  PHP is current at 5.4+ and MySQL is current at 5.6+

Once that is done, create a simple "hello world" example for the Shortcode Exec PHP tests, just something to verify that you can run PHP with the plugin.  Then try the changes that seem to be the cause of the current Warning message.  The goal here is to isolate the possible causes of failure.  We want to eliminate old software and incompatible versions, then we want to prove that Shortcode Exec PHP is installed and working correctly.  We may never debug the original problem, but if we can make it go away and stay away, that's progress!

Current WP is 3.8.1
http://wordpress.org/download/

Current Shortcode Exec PHP is 1.50
http://wordpress.org/plugins/shortcode-exec-php/

Current Bad Behavior is 2.2.15
http://wordpress.org/plugins/bad-behavior/
0
 

Author Comment

by:sharingsunshine
Comment Utility
I see now the conflict once you put in the actual links.  I am not using Bad Behavior on WordPress. I am using Bad Behavior on SMF.  I did find out there is an upgrade that wasn't showing in the package manager.  I will be making that change soon and I'll get back to you once I save my settings since they don't have an easy upgrade path for mods.

By the way, I didn't know there was a bad behavior plugin for WP or I would have clarified what bad behavior was involved.

Ray, I do like the approach you are suggesting and I will get back to you after I get it implemented.

Thanks,
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
0
 

Author Comment

by:sharingsunshine
Comment Utility
Yes, that's the one.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Good to be on the same page :-)  Please let us know how it goes, ~Ray
0
 

Author Comment

by:sharingsunshine
Comment Utility
Sorry for the delay, I have done all of the following;

The Hello World example works

I am currently on 5.2.17 and when I upgrade to 5.5.9 then the recent topics option breaks on the regular .html site.

So I am chasing that down to see if I need to upgrade the forum in some way.

I will let you know once that is resolved.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
currently on 5.2.17 and when I upgrade to 5.5.9 then the recent topics option breaks
Assuming you mean PHP Version 5.2.17, right?  

There are a lot of changes in PHP from PHP 5.2 to PHP 5.5.  We would need to know a bit more than "breaks" to begin to assess the issue, for instance, what is the exact symptom of "breakage?"

PHP has a changelog that tells what is new in each release.  You would probably need to start somewhere near these links and read forward in time to find everything that changed.  As you will see, it is quite an extensive research project.
http://www.php.net/ChangeLog-5.php#5.2.17
http://www.php.net/ChangeLog-5.php#5.3.0

The "cannot modify headers" message often occurs because PHP issued a message before the script issued "session_start()" or otherwise tried to use header() or setcookie().  The source of spurious PHP messages has changed over time.  For example, if a PHP script used one of the POSIX functions, it would have been a non-event in PHP 5.2, but would trigger a "deprecated" message in newer releases of PHP.  It's messages like this that can cause scripts to bark.  Another common thing are messages related to the date timezone.  Sometimes a PHP installation has an error_log and you may be able to find the information there.
0
 

Author Comment

by:sharingsunshine
Comment Utility
My error logs are too voluminous they go back to 2011.  So I am in the process of working with my hosting company to remove the old  entries.

When I say it breaks I get this message instead of the Topics showing.
[an error occurred while processing this directive] - See more at: http://www.thefrugallife.com/index.html#sthash.Cub8034O.dpuf

Thanks for your continued patience.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
...error logs are too voluminous...
Hmm... That should be a red flag ;-)

Can you sort in reverse chronological order, maybe?
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
This is a bit of a guess, but the issue could be related to an error in file permissions.

- Files should be set to: 0644 (this is the UNIX file permissions)
- Folders should be set to: 0755

If you have a file named .htaccess it would be helpful to see that, too.  It may contain passwords.  If it does, please obscure those but otherwise post the file in its entirety without any changes, thanks.
0
 

Author Comment

by:sharingsunshine
Comment Utility
the error log all the way back to 2012 has only one message in it and it isn't related to smf or the topics code.

It's related to the application piwik.php which is similar to Google Analytics and it is saying it doesn't have enough memory.

I don't mind sending you the .htaccess but I am reluctant to post its contents.  Do you have some way I can send it to you directly?  I have no passwords but I have how I am blocking spammers from certain countries and if they know the programs I am using they might be able to focus more on breaking those software programs I am using.

SSI.php is set at 644 and the smf enclosing folder is set at 755.

I have toggled the php on and off and I don't see anything in the php error log file.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
You can find my email address in my public profile.  
http://www.experts-exchange.com/members/Ray_Paseur.html
0
 

Author Comment

by:sharingsunshine
Comment Utility
Great, I have sent it.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Lots of stuff in .htaccess!  I was looking for this:

Yours:
AddHandler application/x-httpd-php5 .html .htm

Mine:
AddType application/x-httpd-php5 .html .htm .php

Doubt that has anything to do with it, sorry.
0
 

Author Comment

by:sharingsunshine
Comment Utility
Ray, you have been great and I am sure if I dig into what you said up here

PHP has a changelog that tells what is new in each release.  You would probably need to start somewhere near these links and read forward in time to find everything that changed.  As you will see, it is quite an extensive research project.
http://www.php.net/ChangeLog-5.php#5.2.17
http://www.php.net/ChangeLog-5.php#5.3.0

that I could find the answer as to why that part is not working anymore with 5.5.9.

So I am inclined to award you the points on that section and both move on.  Do you agree?
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
Make sure you have "log errors" set on in php.ini because it should tell you if something is issuing any messages.  My belief is still that there is something barking out a message, perhaps at the time of connection to the data base (since MySQL is deprecated at PHP5.5) and this message is what causes the "cannot send headers" condition.

Wish I could see it "live" to check the server, but alas.
0
 

Author Comment

by:sharingsunshine
Comment Utility
I found another error log specific to the smf forum.  I'll have it downloaded by tonight so I expect it will reveal what is going on.

I had forgotten that I have a specific php.ini for smf and when I looked at log errors it said yes and specified a different file than what I had been looking at.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
That's probably good news!  Hope there is a strong clue in there.
0
 

Author Comment

by:sharingsunshine
Comment Utility
I was hoping so too but I am not clear on what the problem is but it has been going on since 2011.

Undefined index:  server in smf/Sources/QueryString.php on line 477

Open in new window


this is the code at line 477 starting with the word if

// This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo.
	if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || @ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd']))
	{

Open in new window


Here is a response to this problem on the forum for SMF

http://www.simplemachines.org/community/index.php?topic=516346.msg3651829#msg3651829
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Undefined Index is a Notice, not an error.  In the "default" installation of PHP, the Notice level messages are suppressed.  The programmers probably never turned the error_reporting() level up, and thought they could just ignore what they didn't see.  But in the current installation, the Notice messages are being raised.  You might try setting the reporting level with this:

error_reporting(E_ALL ^ E_NOTICE);

Open in new window

0
 

Author Comment

by:sharingsunshine
Comment Utility
I have found some errors in the code and I am not sure it is related or not.  So I will need to do some digging into it.  In the meantime, because of your direction I feel I am headed in the right direction.  So thanks for all your help.
0
 

Author Closing Comment

by:sharingsunshine
Comment Utility
Very helpful and knowledgeable.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points and thanks for using EE, ~Ray
0
 

Author Comment

by:sharingsunshine
Comment Utility
You earned them and EE has been a big help to me.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Glad to hear that!

All the best, ~Ray
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now