Zen Cart Logo
Forums / General Questions / Headers Already Sent

Headers Already Sent

Views: 1,831

Results 1 to 14 of 14
27 Apr 2011, 6:29 PM
#1
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Headers Already Sent

I could use some help trying to track down this error:

[27-Apr-2011 12:46:08] PHP Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/includes/templates/template_default/common/html_header.php:22) in /home//public_html/includes/functions/functions_general.php on line 45

I have spent many hours trying to find the culprit, and just cannot seem to find it. I have looked for the extra spaces before/after in all my header_php.php files to no affect. I've tried to reproduce the error browsing through my site and hitting all the major pages and still no go. Yet I still get 6 to 10 of these debug logs a day.

Yes, I have read the wiki entry on this, but those suggestions have not helped.

Zencart 1.3.9h

Thanks! Hope someone has an idea.

27 Apr 2011, 7:59 PM
#3
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Headers Already Sent

haredo:

have you read this in the tutorial section..

Yes, that's what I mistakenly called the wiki entry :P

27 Apr 2011, 11:30 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Headers Already Sent

It means you've got something doing "output" on line 22 of /includes/templates/template_default/common/html_header.php

Moving this out of the Bug Reports section, since it's not a core bug of ZC.

29 Apr 2011, 1:33 PM
#5
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Headers Already Sent

Well, this IS an unmodified core file.

Line in question:

<html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?>>

Could these error be produced by some form a hack/sql injection ???

These errors are occurring on a site without any user login, or checkout (royal industries inc <dot> com). I can browse through all the main pages of the site and NOT generate this error, yet I still get several of them every day. If I can't trigger the error myself, how am I ever going to track down the cause.

Some direction on what I need to do would be appreciated.

thanks

29 Apr 2011, 1:41 PM
#6
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,179
Plugin Contributions:
0

Re: Headers Already Sent

Use the free program called Winmerge to compare the two html_header.php files side by side.

You will compare the one that is on your server right now with one from the zen cart download file you are presently using..

  1. This show any differences between the two files...
29 Apr 2011, 2:20 PM
#7
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Headers Already Sent

hi haredo,

yes, I've done this (but on the Mac I use Kdiff3 and DiffMerge).

I have in fact carefully check over all the files under /includes/modules/pages/*** pick a page ****/header_php.php

all to no affect.

29 Apr 2011, 3:20 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Headers Already Sent

Okay, so maybe your problem isn't with header_php.php files nor html_header.php.

It's possible that you've customized something that's attempting to do a zen_redirect or is making a header() call from within a main_template_vars file or a template file, which will cause this sort of problem because you can't do a redirect like that once output has been sent to the page, and since html_header.php is where the output first starts (just as the error message says), it's just showing you a symptom, not a root cause.

So, since the header_php file load first, then html_header, and then the main_template_var files and then all the templating system, you need to focus in the latter sections.
Ref: http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_54&products_id=378

29 Apr 2011, 4:22 PM
#10
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Headers Already Sent

Hi Doc,

Thanks for the additional info. I had previously read this thread:

http://www.zen-cart.com/forum/showthread.php?t=79162

The final post about a blank line at the end of english.php sounds like what you are referring to. This is very possibly the issue, and one I hadn't considered. I have been working in some of these files, as well as several custom defined pages files (like the about_us page).

I did have a blank line at the end of my english.php file. I see in 1.3.9h that the closing ?> has been removed, but this is still in my code... perhaps I missed it or didn't consider it when merging files during my upgrade to 1.3.9h.

I'll check through all these carefully, and also read through the program flow documentation.

Thank you for the additional help and info. Nothing quite like having a "space" kick your arse for days on end!

Another customization that I did that may be related to this is forcing SSL on certain pages. But I have performed these on other sites without issue.

-cj

DrByte:

Okay, so maybe your problem isn't with header_php.php files nor html_header.php.

It's possible that you've customized something that's attempting to do a zen_redirect or is making a header() call from within a main_template_vars file or a template file, which will cause this sort of problem because you can't do a redirect like that once output has been sent to the page, and since html_header.php is where the output first starts (just as the error message says), it's just showing you a symptom, not a root cause.

So, since the header_php file load first, then html_header, and then the main_template_var files and then all the templating system, you need to focus in the latter sections.
Ref: http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_54&products_id=378

29 Apr 2011, 6:12 PM
#11
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Headers Already Sent

One more quick question!

There are a lot of files under /includes/languages/... some that terminate with "?>" and others that don't.

Granted, there should be no spaces/lines after "?>" .... unless there is some exception I am unaware of .... but is the enclosing "?>" ever actually required?

Thanks!

29 Apr 2011, 8:18 PM
#13
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Headers Already Sent

I believe I found my problem code!!

One of my define pages contains code that is supposed to only allow users that are logged in to see, and if not logged in, to tell them they must be logged in, and push them to the login page:

<?php if ($_SESSION['customer_id']) { ?>

<div>
This Content is Viewable when logged in.
</div>

<?php } else { ?>

You must log-in to view this content.<br><br>

<?php 
$_SESSION['navigation']->set_snapshot();
  zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL')); ?>

<?php } ?>

It is be the zen_redirect() that is triggering the error! Is there another way to do what I want? I must be using this code incorrectly.

Thanks!

29 Apr 2011, 9:23 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Headers Already Sent

Put it in the page's header_php.php file instead.