News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

cannot modify header information....

Started by DarkAngel612, July 09, 2013, 07:36:21 PM

Previous topic - Next topic

DarkAngel612

Yes I know that there are many entries involving this situation with the referring file as errors.php line350-357

from only one domain on our vps to now 2 of them. hostgator recently migrated our files to a new server and I was hoping this would take care of this situation but it has not. It instead gave us another error that when posting or replying we would get a content error page that would still at times continue to do the post or reply but often getting it 3 or 4 times in a row.

on thefantasiesattic files I went so far as to put the forum in maintenance mode then replace all SMF 2.0.4 files which meant that I also needed to reinstall the mods too AFTER I ran the updater that came with the upgrade zip too.

it seems to have cleared up the content error for that forum and also the reuploading of the settings.php files. but it is in no way stopping the other error.

ideas aside from checking for an intruding space after the ?> especially since all the files are fresh from unzipping fresh zips from here.
Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

MrPhil

As part of the error message, it should tell you where the output to the browser was started. It should say something like "Output started at..." and give a file and line. If it includes "eval", go to Admin and turn off template evaluation. Once you have the file and line, you can examine that file closely to see if there is a stray space or Byte Order Mark before the first <?php or after the last ?>. If your page is UTF-8, put it in Latin-1 (aka Western European, ISO-8859-1) to make any BOM show up. You can also look at a page's HTML source (View > Page source in the browser) and see if there's some actual error message lurking in there that you overlooked.

Kindred

I should note that we have seen several issues lately with hosts who "moved content" and they apparently ended up transferring it incorrectly and getting random character inserted at the beginning or end of the file...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

DarkAngel612

it says this: output started at then the path/Sources/Errors.php:419 in path/Sources/Errors.php on line then it is just repeated for each line of 350-357

I was getting this error at the fantasies attic, now get it at fantasiesrealm.com as well as 1 subdomain on the attic server.

I have since the migration, reuploaded fresh smf files then reinstalled all my mods then checked for stray lines att beginning and end of ALLLLLLLLL the many files and sure don't see any.

I have no clue how to do the change from utf8 to latin without attacking the database

for the html source would I look at any forum page or the actual file the error is calling for?


Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

MrPhil

QuoteI have no clue how to do the change from utf8 to latin without attacking the database
You don't change anything in your forum. It's just a temporary change in the browser.

Quotefor the html source would I look at any forum page or the actual file the error is calling for?
Bring up a page where you're getting the "cannot modify..." error. Something like "View > Character Encoding" (or similar) in the browser will let you change from UTF-8 to Latin-1 (temporarily). See if a group of three funny characters (upside-down-?, i+umlaut, >>) shows up at the very beginning of the page. If it does, that's a BOM and it needs to be removed from any file it lives in. Usually it was a language file edited in UTF-8 that someone saved with a BOM, rather than without. A BOM is always the very first thing in a file.

You can also look at the HTML page source from the browser (View > Page Source or similar). It may show you earlier error messages that you overlooked, or stray/extra blanks or other crap at the beginning of the page. If you see such things, you will need to remove them from one or more files.

DarkAngel612

Quote from: MrPhil on July 10, 2013, 09:21:43 AM
QuoteI have no clue how to do the change from utf8 to latin without attacking the database
You don't change anything in your forum. It's just a temporary change in the browser.

Quotefor the html source would I look at any forum page or the actual file the error is calling for?
Bring up a page where you're getting the "cannot modify..." error. Something like "View > Character Encoding" (or similar) in the browser will let you change from UTF-8 to Latin-1 (temporarily). See if a group of three funny characters (upside-down-?, i+umlaut, >>) shows up at the very beginning of the page. If it does, that's a BOM and it needs to be removed from any file it lives in. Usually it was a language file edited in UTF-8 that someone saved with a BOM, rather than without. A BOM is always the very first thing in a file.

You can also look at the HTML page source from the browser (View > Page Source or similar). It may show you earlier error messages that you overlooked, or stray/extra blanks or other crap at the beginning of the page. If you see such things, you will need to remove them from one or more files.

the page indicated would be the Sources/Errors.php:419 I tried going to it via browser and got a message Hacking attempt.

will try the other today to see whats up.

thanks
Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

Kindred

you can not directly access any SMF files except for index.php
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MrPhil

You would just do whatever you normally do, that happens to bring up the "cannot modify..." message. Then you look at the screen and HTML source to see if you can get a clue as to what triggered the original message.

DarkAngel612

yesterday on of the admins sent me the error---first time to actually show in the forum, otherwise no idea of it until I go to server files and there is the error_log with nothing in the cache folder

he said he tried to post a reply (has done that also and gotten the content error  to come up) and it had llisted on the page numerously (matching each of the lines written about above.

no idea what is going on but willl try it the next time he gets it for I have not gotten it at all. also the post reply did go through---6 times so he had to delete the extra ones.

I am also going to recheck the files again just to make triple sure there are no extra lines before or after the <> lines...

the acutal lines in errors.php are with red ones the actual line numbers in log:

// Just check we're not in any buffers, just in case.
    for ($i = ob_get_level(); $i > 0; $i--)
        @ob_end_clean();

    // Don't cache this page!
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: no-cache');

    // Send the right error codes.
    header('HTTP/1.1 503 Service Temporarily Unavailable');
    header('Status: 503 Service Temporarily Unavailable');
    header('Retry-After: 3600');

    if ($loadavg == false)
    {
        // For our purposes, we're gonna want this on if at all possible.
        $modSettings['cache_enable'] = '1';


        if (($temp = cache_get_data('db_last_error', 600)) !== null)
            $db_last_error = max($db_last_error, $temp);

        if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send))
        {
            require_once($sourcedir . '/Subs-Admin.php');
the error states Errors.php:419 --- if that is another code line then it is a blank line between } and ?>:
die;
}

?>

all the checking and looking for the error may take a bit so will return when I get more news, thanks
Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

MrPhil

You're looking first for an error message fragment that says "output started at..." and gives a file and line number. That should greatly reduce the amount of searching you need to do. You then want to look and see if there's a Byte Order Mark, spaces, or a PHP error message up at the very top of the screen. Between those you should find what happened.

Just give us a URL to the page that's showing the error, and I can see what I can do. If you'd rather not make it public, you can PM it to me.

DarkAngel612

ok here is the actual error from an older error_log from one of the subforums.

[09-Jul-2013 17:58:07] PHP Warning:  Cannot modify header information - headers already sent by (output started at /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php:419) in /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php on line 350
[09-Jul-2013 17:58:07] PHP Warning:  Cannot modify header information - headers already sent by (output started at /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php:419) in /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php on line 351
[09-Jul-2013 17:58:07] PHP Warning:  Cannot modify header information - headers already sent by (output started at /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php:419) in /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php on line 352
[09-Jul-2013 17:58:07] PHP Warning:  Cannot modify header information - headers already sent by (output started at /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php:419) in /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php on line 355
[09-Jul-2013 17:58:07] PHP Warning:  Cannot modify header information - headers already sent by (output started at /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php:419) in /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php on line 356
[09-Jul-2013 17:58:07] PHP Warning:  Cannot modify header information - headers already sent by (output started at /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php:419) in /xxx/xxx/public_html/jherriths-lair/Sources/Errors.php on line 357

This is the exact same way they all were.....today wouldn't you know it--not a single log in attic or market...just like car trouble talk to mechanic and it goes away for awhile making you feel like an idiot.

I did as I said replace all smf files in both attic and store...got the error-log in attic once yesterday none today in either attic nor store.

Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

MrPhil

#11
This is SMF 2.0.4? You're missing a LOT of code compared to my copy of Errors.php. The "// Send the right error codes" line is number 350 (out of 420 in the file) in my file. After the "   require_once($sourcedir . '/Subs-Admin.php');" line, I have around 49 lines of code before the "die;" line. Does the portal remove all that code? How did you get the same line 419 that I show? I'm confused.

If what you posted is complete, there appears to be at least two levels of  nested { } that are still open at the end of the file. Are you sure you're not getting error messages on-screen like "Unexpected $end"? Or did you just clip out a lot of code in your post?

       // Don't cache this page!
350    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
351    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
352    header('Cache-Control: no-cache');

        // Send the right error codes.
355    header('HTTP/1.1 503 Service Temporarily Unavailable');
356    header('Status: 503 Service Temporarily Unavailable');
357    header('Retry-After: 3600');

The line numbers above would be what your reported errors are indicating. They are 346-8 and 351-3 in my copy. Any idea why the 4 line discrepancy? And 419 in your copy would probably be 415 in mine (the end of the echo of the error page "What to do?"). At the very least, check for stray blanks etc. after that closing ?>. However, I suspect the "unexpected text" was that error page HTML code for "Connection problems". I wonder why your forum didn't die a line later, rather than keep going?

DarkAngel612

well cause like the idiot that I am...I entered in the post the lines from the file that is found in the actual SMF 2.0.4 zip, sorry

I am attaching the file from my server, if the board allows that and also the one from the zip with the tlde at the end showing file without any modifications.
Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

MrPhil

OK, the end of it looks complete. Your copy has 4 lines added in "function fatal_error()" to do something with initializing TinyPortal. I won't be able to compare it against a stock copy of Errors.php until tonight or tomorrow, but the line count is the same in the previous copy (Errors.php~).

If the "unexpected text" (issued before all the header() stuff) was the error page about "Unable to connect", SMF should have hit the die; call and quit right after. I'm a bit puzzled as to why SMF apparently keeps running, only to go through Errors.php again. The second time around (and third, and fourth,...) Errors.php tries issuing header() calls again, and since some text has already been sent to the browser, you'll get the "cannot modify..." errors. But Errors.php should never have been called a second time!

Just for giggles, you might try replacing
die;
at the end of the Errors.php file with
echo "ERROR";  exit(1);
and see if it makes any difference. die is supposed to be like exit, but maybe something strange is going on. You might even try just adding () to die:
die();
in case it's not being recognized as a system function call for some reason.

DarkAngel612

Well Mr. Phil...thanks for the input and IF the silly thing starts up again I will try that. It has stopped for now.

None of the files had any extra lines except 2 of the mods files that were inserted. I removed the extra line at the bottom and hope that the site is happy once more.


Fantasy Attic ::  Fantasies Realm Market :: SMF 2.0+ with various mods and TinyPortal

Advertisement: