Jump to content



Photo
* * * * * 1 votes

"Headers already sent..."


This topic has been archived. This means that you cannot reply to this topic.
35 replies to this topic

#1   germ

germ
  • Members
  • 13,921 posts

Posted 12 June 2011 - 22:32

"Headers already sent" help contribution
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#2   sunshynecraftsbeads

sunshynecraftsbeads
  • Members
  • 144 posts

Posted 23 June 2011 - 23:16

Hi Jim,

Thank you for the information and the contribution. I have installed it and brought up the output start at folder as mentioned in your read me notes. The following is what comes up when I hit go.

I opened the php file and reviewed everything looking for these the comments on the report but there is nothing that has the <?php[0D][0A] or the ?>[0D][0A][0D][0A] mentioned ? I even did a search within the php file.

It says that the php file has 91 lines but when I open my php file in code editor it shows my last line to be 90 and it says ?>


Am I missing something here Jim. Please advise when you have a minute. Thank you so much in advance for provided me with more information. I will also continue to check things in the mean time. I am not sure why this has happened since I have not touched my shipping folders for weeks.



/home/sunshyn1/public_html/includes/modules/shipping/airinternational.php has 91 lines.
The PHP start tag is on line 1.
The PHP end tag is on line 90.
Contents from start of file to the PHP start tag:

<?php[0D][0A]

-------------------------
Contents from PHP end tag to end of file:

?>[0D][0A]
[0D][0A]


Error Messages:

The closing PHP tag is not on the last line in the file.


-------------------------
The requested line [92] is out of range.



#3   toyzonline

toyzonline
  • Members
  • 327 posts

Posted 23 June 2011 - 23:24

Put your cursor after the ?> and press delete.

I know it sounds daft but dont reply on a visual inspection

Ricardo

#4   sunshynecraftsbeads

sunshynecraftsbeads
  • Members
  • 144 posts

Posted 23 June 2011 - 23:32

Thank you so much Jim & Ricardo. That did the trick. I am up and running again with no errors.
You guys are the best !!!!!! /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' />

#5   sunshynecraftsbeads

sunshynecraftsbeads
  • Members
  • 144 posts

Posted 23 June 2011 - 23:42

Put your cursor after the ?> and press delete.

I know it sounds daft but dont reply on a visual inspection

Ricardo



Thank you so much Jim & Ricardo. That did the trick. I am up and running again with no errors.
You guys are the best !!!!!! /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' />

#6   BretSpark

BretSpark
  • Members
  • 32 posts

Posted 23 August 2011 - 15:09

Hi Guys,
i am haveing a small problem with this addon, i have installed and configured it as per the installing guide. everything shows up ok when i enter it under the admin section.
The problem i have is the editor seems to add extra characters. for example if i type "testing" it comes up as

rn testing
rn

Any ideas? for some strange reason it seems to be placing Windows Return characters in my text.

Regards

Bret

#7   germ

germ
  • Members
  • 13,921 posts

Posted 27 August 2011 - 15:36

Hi Guys,
i am haveing a small problem with this addon, i have installed and configured it as per the installing guide. everything shows up ok when i enter it under the admin section.
The problem i have is the editor seems to add extra characters. for example if i type "testing" it comes up as

rn testing
rn

Any ideas? for some strange reason it seems to be placing Windows Return characters in my text.

Regards

Bret

I'm thinking you posted in the wrong topic.
/blush.gif' class='bbc_emoticon' alt=':blush:' />

I'll post the contents of the "readme" that is in my contribution so you won't have to download it.

"Headers already sent"
----------------------

The offical explanation:

http://www.oscommerc...der Information

Using osC you can't have output to the browser before the session is started (normally in /catalog/includes/application_top.php).

What this really boils down to is the opening php tag ( <?php ) must be at the beginning of the php file, and you cant have anything more that the O/S [eol] after the closing php tag ( ?> ).

If you have any blank lines or spaces or other characters (seen or unseen) in front of the opening tag or after the closing tag you can get the "Headers already sent" error.

Saving a file in UTF-8 format with the Byte Order Mark (BOM) will also cause this error.

The thing about it is since most of the time it's "whitespace(s)" (jargon for "what you can't see") it can be difficult to find the source, let alone fix it.

Then to add "insult to injury" the PHP errors that appear on the page aren't much help.

A few examples taken from the forum:

Warning: Cannot modify header information - headers already sent by (output started at /htdocs/public/www/includes/languages/espanol/modules/payment/transfer.php:19) in /htdocs/public/www/includes/functions/general.php on line 33

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mounted-storage/myshop.com/index.php(1) : eval()'d code:37) in /mounted-storage/myshop.com/includes/functions/sessions.php on line 102

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/html/includes/functions/database.php:307) in /home/html/includes/functions/sessions.php on line 203

Notice that in each case TWO FILES are mentioned! So where does one look?

The very simple answer is: ALWAYS look in the file where the error message says "output started at".

And at the end of that part of the error message a "line number" is given.

I've writen a small helper utility if you have difficulties finding the problem.

Upload the headsent.php file in this contribution into your "catalog" folder. Then access it with your browser.

You are then presented with a "File:" box, an "Optional Line #:" box and a "Do it" button.

Most times just type the the path to the file with the error into the "File:" box then hit [enter] or click the "Do it" button.

More on the "Optional Line #:" box later.

Let's look at each if the three example errors and I'll expand on the contribution's use.

Example No. 1
-------------

Warning: Cannot modify header information - headers already sent by (output started at /htdocs/public/www/includes/languages/espanol/modules/payment/transfer.php:19) in /htdocs/public/www/includes/functions/general.php on line 33

This person would upload headsent.php into the "www" folder, and in the box type: includes/languages/espanol/modules/payment/transfer.php

The offending line in that case is line number 19.

Example No. 2
-------------

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mounted-storage/myshop.com/index.php(1) : eval()'d code:37) in /mounted-storage/myshop.com/includes/functions/sessions.php on line 102

This person would upload headsent.php into the "myshop.com" folder, and in the box type: index.php

The offending line in that case is line number 1. This shop had been hacked.

Example No. 3
-------------

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/html/includes/functions/database.php:307) in /home/html/includes/functions/sessions.php on line 203

This person would upload headsent.php into the "/home/html/" folder, and in the box type: includes/functions/database.php

The offending line in that case is line number 307.

Now, more about the "Optional Line #:" box.

Most of the time the "Headers already sent" error is because of "whitespaces" or other content at the beginning or end of a file.

I have seen it where there is a php "echo" or other content in the middle of a file that shouldn't be there.

Mostly from downloaded contributions where the developer had some "debug" code they forgot to remove before uploading the contribution.

So if you have a "Headers already sent" problem with a file and the error is on line number say 199 and the file has say 247 lines you know the problem isn't at the end of the file.

And it probably doesn't have 198 blank lines at the beginning of the file so that's where you'd use the "Optional Line #:" box to have the program display that line from the file in your browser.

What should the ouput look like when you run the program?

Normally like this (UNIX O/S):

Contents from start of file to the PHP start tag:

<?php[0A]

-------------------------
Contents from PHP end tag to end of file:

?>[0A]

Or like this (Windowz O/S):

Contents from start of file to the PHP start tag:

<?php[0D][0A]

-------------------------
Contents from PHP end tag to end of file:

?>[0D][0A]

If you have a blank line at the beginning of the file it might look like this:

Contents from start of file to the PHP start tag:

[0A]<?php[0A]

If you saved a file in UTF-8 format with the BOM it might look like this:

Contents from start of file to the PHP start tag:

[EF][BB][BF]<?php[0A]

If you have an extra blank line at the end of the file it might look like this:

Contents from PHP end tag to end of file:

?>[0A][0A]


If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#8   ssfcsv

ssfcsv
  • Members
  • 21 posts

Posted 23 January 2012 - 23:48

Thank you for writing this Jim.

#9   apolyshow

apolyshow
  • Members
  • 244 posts

Posted 18 February 2012 - 17:16

i am having this issue

Warning: Cannot modify header information - headers already sent by (output started at /home/iliofosg/public_html/eshop/downunder/includes/template_top.php:14) in /home/iliofosg/public_html/eshop/downunder/includes/functions/general.php on line 35

and with the headsent.php i am taking this

O/S = Linux.
downunder/includes/template_top.php has 74 lines.
The PHP start tag is on line 1.
The PHP end tag is on line 72.
Contents from start of file to the PHP start tag:

<?php[0A]

-------------------------
Contents from PHP end tag to end of file:

?>[0A]
[0A]
<div[20]id="contentText">[0A]


Error Messages:

The closing PHP tag is not on the last line in the file.


-------------------------
Extended contents of the requested line [14] are:

<html[20]<?php[20]echo[20]HTML_PARAMS;[20]?>>[0A]

-------------------------
Raw contents of the requested line [14] are:

>


What do i have to do?
One amateur made the Arc, 5.000 pro made the Titanic...

#10   ogwinilo

ogwinilo
  • Members
  • 150 posts

Posted 28 February 2012 - 07:54

I have a similar problem. I have deleted spaces on each ends of the file, replaced the languages.php file with one that is exactly the same and working in another site, but still no joy.

This is the message received;
Deprecated: Function eregi() is deprecated in /home/woiqqwab/public_html/yebocom/admin/includes/classes/language.php on line 87

Warning: Cannot modify header information - headers already sent by (output started at /home/woiqqwab/public_html/yebocom/admin/includes/classes/language.php:87) in /home/woiqqwab/public_html/yebocom/admin/includes/functions/general.php on line 22

Any help will be appreciated

Regards

Felix

#11   MrPhil

MrPhil
  • Members
  • 5,157 posts

Posted 28 February 2012 - 18:57

Your problem is that your server has moved up to PHP 5.3, and you're still running old code that's incompatible with this PHP version. Go searching on "eregi" and you'll find plenty of discussion on it. Once that's fixed, the "Cannot modify header information" error will go away all by itself.

#12   ogwinilo

ogwinilo
  • Members
  • 150 posts

Posted 29 February 2012 - 04:40

@MrPhil

thanks MrPhil, will look it up

#13   arkisaeo

arkisaeo
  • Members
  • 65 posts

Posted 14 May 2012 - 18:11

Having similar trouble (even after using this contrib).

Here's the message:

Warning: Cannot modify header information - headers already sent by (output started at *******/admin/products_attributes.php:18) in *******/admin/includes/functions/general.php on line 34


Here is what I got from using the contrib:

O/S = Linux.
admin/products_attributes.php has 1047 lines.
The PHP start tag is on line 1.
The PHP end tag is on line 1047.
Contents from start of file to the PHP start tag:

<?php[0A]

-------------------------
Contents from PHP end tag to end of file:

?>

-------------------------
Extended contents of the requested line [18] are:

<script[20]type="text/javascript">[0A]

-------------------------
Raw contents of the requested line [18] are:



This is what's on line 34 of the admin/includes/functions/general.php file:

header('Location: ' . $url);


#14   germ

germ
  • Members
  • 13,921 posts

Posted 14 May 2012 - 20:38

Post the first 25 lines of *******/admin/products_attributes.php
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#15   Ingo Bingo

Ingo Bingo
  • Members
  • 43 posts

Posted 13 June 2012 - 10:33

Hi There, i get this message

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /homepages/46/d86206271/htdocs/pete/accuity/catalog/includes/edit-wysiwyg.php:20) in /homepages/46/d86206271/htdocs/pete/accuity/catalog/plad/includes/functions/sessions.php on line 67

i plugged includes/edit-wysiwyg.php and i got this answer any ideas please?

O/S = Linux.
includes/edit-wysiwyg.php has 27 lines.
The PHP start tag is on line 1.
The PHP end tag is on line 27.
Contents from start of file to the PHP start tag:

<?php[20][0A]

-------------------------
Contents from PHP end tag to end of file:

?>[0A]

#16   germ

germ
  • Members
  • 13,921 posts

Posted 13 June 2012 - 10:35

Post the whole file (catalog/includes/edit-wysiwyg.php)
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#17   Ingo Bingo

Ingo Bingo
  • Members
  • 43 posts

Posted 13 June 2012 - 10:43

<?php

// this part determines the physical root of your website
// it's up to you how to do this
if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT']))
$_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/';
else
$_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];

define('DR', $_root);
unset($_root);


// set $spaw_root variable to the physical path were control resides
// don't forget to modify other settings in config/spaw_control.config.php
// namely $spaw_dir and $spaw_base_url most likely require your modification
$spaw_root = DR.'spaw/';

// include the control file
include $spaw_root.'spaw_control.class.php';

// here we add some styles to styles dropdown
$spaw_dropdown_data['style']['default'] = 'No styles';
$spaw_dropdown_data['style']['style1'] = 'Style no. 1';
$spaw_dropdown_data['style']['style2'] = 'Style no. 2';
$copy ="Wysiwyg Editor V1.04 modified SPAW for PHPNuke";
?>

#18   Ingo Bingo

Ingo Bingo
  • Members
  • 43 posts

Posted 13 June 2012 - 10:46

The odd thing is i didnt change any files and this error started yesterday, the site has been running for years, please note is is only on the admin panel side of the site not the main customer facing site

Edited by Ingo Bingo, 13 June 2012 - 10:46.


#19   germ

germ
  • Members
  • 13,921 posts

Posted 13 June 2012 - 10:54

The real error is here:

Warning: main(/etc/apache2/htdocs/spaw/spaw_control.class.php) [function.main]: failed to open stream: No such file or directory in /homepages/46/d86206271/htdocs/pete/accuity/catalog/includes/edit-wysiwyg.php on line 20

If you haven't changed anything you may be hacked.

I found vulerabilities listed online for spaw_control.class.php

If your file hasn't been patched you may be a hack victim.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#20   Ingo Bingo

Ingo Bingo
  • Members
  • 43 posts

Posted 13 June 2012 - 10:57

i know it sounds daft but what do i do now?