sparking header modifiy warning

[09-Jun-2016 22:40:37 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at …/wp-content/themes/sparkling/header.php:12) in …/wp-content/themes/sparkling/header.php on line 23

Hi @mu92,

I hope you are well today and thanks for posting here.

I have tested it on my test site and it’s working fine for me using latest version of Sparkling theme. I am not getting any such warning message even setting WP debug to true.

Have you made any changes in the theme files?

Please try deleting and reinstalling latest version of theme.

This is a simple PHP warning and most of the time it doesn’t affect functionality of site so it is nothing to worry about!

Do you have WP_DEBUG set to true in your wp-config.php file?

If you do then please set it to false.
This will hide the warning messages and you will be able to use your site normally.

Best Regards,
Movin

For me, the warning was thrown by line 23 within the header.php. Removing it causes the error to disappear (at least in my case).

Even if this error is “nothing to worry about”, best practice would be to deal with it so it doesn’t muddy the waters if you should have another issue later on!

@loni2shoes As said above i have tested it on my test site and it’s working fine for me using latest version of Sparkling theme. I am not getting any such warning message even after setting WP debug to true.

The code that is producing the error is on line 23the header.php of the theme.

The only way for you to get that error is if you are using Internet Explorer. You are calling the header function after the header is already sent which is why some are getting that error.

Instead of using the header function to add the X-UA-Compatible simply echo the the meta for it.

I tried posting the code but it would not allow me to.

Anyhow, did this myself and it fixed it :slight_smile:

@Barry Thank you for providing your valuable information here.

Your help here is really appreciated.

@mu92 @loni2shoes Could you please confirm here that you are getting this error only on Internet Explorer browser as @Barry described above?

@Movin No problem. Attempted to post the correct code in my reply but it wouldn’t allow me to.

Actually, the error was being thrown when I ran a malware scan of my site using the Sucuri Security plugin.

Hi,

@loni2shoes not sure about the error you are getting. The only thing I know is about the “headers already sent” error that is generated because I got the same error. The solution to that I have.

I was getting the same error. It was thrown when performing a malware scan (though, in this case, it’s not a symptom of malware). As stated above, I corrected the error by removing line 23 (the same line you later echoed).

Hi,

Yeah I don’t know anything about a malware scan, all I know is the php error.

The php error is being generated because the header function is being called after the header information has been sent to the browser. This is on line 23, yes. Of course removing this code will also stop the error as well however, removing the code is not really a solution since the X-UA-Compatible is needed there.

Okay, thanks for the heads up. I will use your suggested solution then!

@Barry

No problem. Attempted to post the correct code in my reply but it wouldn’t allow me to.

You should wrap the code in the code symbols as shown in the attached screenshot or you can add that code in the txt file and zip that file then share it here by attaching it to your reply.

Also if you could confirm the issue on your then could you please report it to the theme developer on the following page?

@Barrylangdon … I am getting the same error for Internet Explorer. Could you please share the code fix as @Movin has mentioned?

@hesham Unfortunately I can not. When I try to add code here it gives me an error.

@Movin yes I was already aware of that and I still get the error.

Could you please share here whole page screenshot of the error message?

@barrylangdon … You can use any Free code sharing service to share it with us. i.e.

@movin … I am seeing the error in the error.logs file for users visiting my website. Until now i’ve got this error more than 300 times in just 3 days:

[11-Nov-2016 15:09:24 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/zico/public_html/wp-content/themes/sparkling/header.php:12) in /home/zico/public_html/wp-content/themes/sparkling/header.php on line 23

@hesham here you go http://www.codesend.com/view/3ba28ce477522b12e0295c7de6daba57/

@barrylangdon … Thanks a lot for this :slight_smile:
I have added this now to my code and i am checking the error logs to see the result.

Appreciated …