[MSU Sitemaps] Headers already sent

Technical difficulties? Ask for help here.
BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

[MSU Sitemaps] Headers already sent

Postby BlessIsaacola » Thu Sep 04, 2008 11:29 am

I just looked in the log today and I am getting the following error message:

[Thu Sep 04 08:44:51 2008] [error] PHP Warning: Cannot modify header information - headers already sent by (output started at /WEBADDRESSREMOVED/sitemaps.php:151) in /WEBADDRESSREMOVED/sitemaps.php on line 93

Any ideas?

Thanks!
http://www.clevershoppers.com - Where Clever People Shop!

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby inveo » Thu Sep 04, 2008 11:43 am

MSU Sitemaps uses Zen Cart core files and you have probably some spaces in your Zen Cart files before <?php or after ?>.

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby BlessIsaacola » Thu Sep 04, 2008 12:50 pm

and why is this a problem now not before? I've being using MSU sitemap since its inception. Having a space after ?> is NOT a technical or code problem. In fact there are several files that the Zen Cart team and other mod creators left a blank space at the end of ?>.

I don't even get the correllation and how this makes any sense....
http://www.clevershoppers.com - Where Clever People Shop!

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby inveo » Thu Sep 04, 2008 12:56 pm

BlessIsaacola wrote:and why is this a problem now not before?


You answer your own original question - someone made changes to Zen Cart files.

BlessIsaacola wrote:Having a space after ?> is NOT a technical or code problem. In fact there are several files that the Zen Cart team and other mod creators left a blank space at the end of ?>.


Yes and there are several errors left by Zen Cart team and mod creators, but only carriage return is allowed after ?>.

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby BlessIsaacola » Sat Sep 06, 2008 3:49 pm

Does anyone see any problem with this block of code?

Code: Select all

$sitemap = strtolower(trim($_GET['showMap']));
   if(strpos($sitemap, 'http://') === false && strpos($sitemap, '..') === false && file_exists(UN_FULLAPP_PATH.SM_DIR_SITEMAPS.'/'.$sitemap.'.php')) {
      require(UN_FULLAPP_PATH.SM_DIR_SITEMAPS.'/'.$sitemap.'.php');
   } else {
      header("HTTP/1.1 404 Document Not Found");
      exit();
   }


Line 93 is:

Code: Select all

header("HTTP/1.1 404 Document Not Found");


Code: Select all

function siteMap($url) {
      $this->timeZone = substr(date('O'), 0, 3);
      header('Content-Type: application/xml; charset=utf-8');
      echo '<?xml version="1.0" encoding="UTF-8"?>';
      $this->baseUrl = $url;
   }


Line 151 is:

Code: Select all

echo '<?xml version="1.0" encoding="UTF-8"?>';


If there is no problem with the code, does anyone know how to make this code smarter to check for header before redeclaring it. In others words, if header is already declared move on and don't try to do it again (thereby triggering the error).
http://www.clevershoppers.com - Where Clever People Shop!

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby inveo » Sat Sep 06, 2008 4:07 pm

As I already said, this has nothing to do with MSU Sitemaps, so someone may have similar problems but only in case that some scripts are break as described before. If you are unable to find which part of your Zen Cart installation files start output untimely, place following code to the beginning of sitemaps.php:

Code: Select all

ob_start();


I am little sad you still don't trust me :( This is one of the PHP basics.

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby BlessIsaacola » Sat Sep 06, 2008 5:24 pm

It doesn't have anything to do with not trusting you. You know that I am an avid endorser of this mod on Zen Cart forum and I try to contribute to this forum as well when I can. The frustration comes when you simply just assume one is trashing MSU related product when there is a problem posted. I think you take things way too personal with the mod.

I simply posted the problem I was experiencing with sitemap and I never said it was MSU sitemap problem. Obviously, it's probably due to an editor messing up one of the 1,000s of files on the server. Unfortunately, I don't know which one (if I did I would have removed the extra blank space). Since at this time, sitemap is the only mod that is triggering this error, that's why I posted here.

Even in a perfect world there will be mod conflicts so that's not what's important to me... it's getting to the solution of the problem that I am interested in.

I basically posted originally looking for help and you basically said this is NOT MSU Sitemap problem which nobody said it was. I was just looking for people to brianstorm with me to get to the bottom of the problem I am experiencing.

I will add the code you provided and report back.

Thanks!
http://www.clevershoppers.com - Where Clever People Shop!

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby BlessIsaacola » Sat Sep 06, 2008 5:30 pm

I actually tried to follow this http://www.hostingfanatic.com/webdev/ph ... -sent.html to see if I can use it to figure out the problem but to no avail.
http://www.clevershoppers.com - Where Clever People Shop!

BlessIsaacola
Follower
Posts: 98
Joined: Sun Feb 03, 2008 9:48 pm
Location: Kennesaw, GA
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby BlessIsaacola » Fri Sep 26, 2008 5:39 pm

I am just thinking out loud.... You do not think that this error: [error] [client 66.249.71.155] PHP Warning: Cannot modify header information - headers already sent by (output started at /sitemaps.php:151) in /home/cshopper/public_html/sitemaps.php on line 93 has anything to do with the Google Sitemap issue I reported earlier do you?

I applied this code:

Code: Select all

ob_start();
from the board which stopped the error from appearing in the log file but I don't know if something is still happening behind the scene.

Do you see any issue on line 151 of sitemaps.php:

Code: Select all

echo '<?xml version="1.0" encoding="UTF-8"?>';
and line 190:

Code: Select all

echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";


Again, I am not saying anything is wrong with the code, I am just thinking out loud. Thanks for the help!
http://www.clevershoppers.com - Where Clever People Shop!

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [MSU Sitemaps] Headers already sent

Postby inveo » Fri Sep 26, 2008 5:57 pm

What is the exact URI where this error occurs? This may happen only when showMap parameter is incorrect and since links with showMap are always correct (not created by human, but by index file) I have no idea why this portion of code is reached.