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

sharingsunshine
sharingsunshine used Ask the Experts™
on
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/
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Year 2014
Top Expert 2014

Commented:
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

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

Commented:
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.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Author

Commented:
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,
Most Valuable Expert 2011
Top Expert 2016

Commented:
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?
Expert of the Year 2014
Top Expert 2014

Commented:
What version of Bad Behaviour are you using?
If not 2.2.10 then upgrade.

Author

Commented:
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
Expert of the Year 2014
Top Expert 2014

Commented:
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?
Most Valuable Expert 2011
Top Expert 2016

Commented:
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/

Author

Commented:
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,
Most Valuable Expert 2011
Top Expert 2016

Commented:

Author

Commented:
Yes, that's the one.
Most Valuable Expert 2011
Top Expert 2016

Commented:
Good to be on the same page :-)  Please let us know how it goes, ~Ray

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

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

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

Commented:
...error logs are too voluminous...
Hmm... That should be a red flag ;-)

Can you sort in reverse chronological order, maybe?
Most Valuable Expert 2011
Top Expert 2016

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

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

Commented:
You can find my email address in my public profile.  
http://www.experts-exchange.com/members/Ray_Paseur.html

Author

Commented:
Great, I have sent it.
Most Valuable Expert 2011
Top Expert 2016

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

Author

Commented:
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?
Most Valuable Expert 2011
Top Expert 2016
Commented:
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.

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

Commented:
That's probably good news!  Hope there is a strong clue in there.

Author

Commented:
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
Most Valuable Expert 2011
Top Expert 2016

Commented:
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

Author

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

Author

Commented:
Very helpful and knowledgeable.
Most Valuable Expert 2011
Top Expert 2016

Commented:
Thanks for the points and thanks for using EE, ~Ray

Author

Commented:
You earned them and EE has been a big help to me.
Most Valuable Expert 2011
Top Expert 2016

Commented:
Glad to hear that!

All the best, ~Ray

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial