j2ee.freelancer Posted December 3, 2009 Share Posted December 3, 2009 Hi, My site was up and running for some time but suddenly it has started giving errors. Error occurs wherever I click submit buttons. The error I am getting is: Warning: Cannot modify header information - headers already sent by (output started at /domains/650/web/fanale/includes/languages/english.php:321) in /domains/650/web/fanale/includes/functions/general.php on line 33 I have looked for blank spaces in my files as well as in particular english.php and general.php. In line 33 of general.php I have define('Location:'.$url) ; Can anyone help me please? Its quite urgent! Thanks. Link to comment Share on other sites More sharing options...
germ Posted December 3, 2009 Share Posted December 3, 2009 Hi, My site was up and running for some time but suddenly it has started giving errors. Error occurs wherever I click submit buttons. The error I am getting is: Warning: Cannot modify header information - headers already sent by (output started at /domains/650/web/fanale/includes/languages/english.php:321) in /domains/650/web/fanale/includes/functions/general.php on line 33 I have looked for blank spaces in my files as well as in particular english.php and general.php. In line 33 of general.php I have define('Location:'.$url) ; Can anyone help me please? Its quite urgent! Thanks. If line 321 is the end of the english.php file and you can't find/remove the whitespaces just delete the closing PHP tag: ?> It will still work without it. 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 > Link to comment Share on other sites More sharing options...
j2ee.freelancer Posted December 19, 2009 Author Share Posted December 19, 2009 [This is superb !! But I could not get the logic behind. I removed the end tag and it worked !! Thanks much. Link to comment Share on other sites More sharing options...
MrPhil Posted December 19, 2009 Share Posted December 19, 2009 The error message says that something at (or about) english.php line 321 was sending text (output) to the browser. This occurred before the osC code had sent its custom headers, so when osC finally did send its custom headers, it was too late -- the default ones had already been sent. Most likely you had some blanks after the closing ?>. After erasing any blank lines at the end of english.php, put the ?> line back in. Make sure there are no blanks or spaces after the >. I don't like germ's advice to leave it off -- that's not good practice and might break something unexpectedly. Normal flow: page started default PHP headers put in HTTP headers table osC PHP code started osC updates HTTP headers with custom settings osC starts outputting text to the browser -- causes current HTTP headers to be sent osC outputs more text (HTML) to the browser Your problem: page started default PHP headers put in HTTP headers table osC PHP code started extraneous blank(s) in one or more files output as HTML text to browser -- causes current HTTP headers to be sent osC tries to update HTTP headers with custom settings -- error, headers already sent In general, the problem is that any text (including blanks) outside the <?php ... ?> gets sent directly to the browser as HTML text. If too early, before osC has updated the HTTP headers the way it wants, the headers will be shipped out too early. Link to comment Share on other sites More sharing options...
germ Posted December 19, 2009 Share Posted December 19, 2009 The error message says that something at (or about) english.php line 321 was sending text (output) to the browser. This occurred before the osC code had sent its custom headers, so when osC finally did send its custom headers, it was too late -- the default ones had already been sent. Most likely you had some blanks after the closing ?>. After erasing any blank lines at the end of english.php, put the ?> line back in. Make sure there are no blanks or spaces after the >. I don't like germ's advice to leave it off -- that's not good practice and might break something unexpectedly. Normal flow: page started default PHP headers put in HTTP headers table osC PHP code started osC updates HTTP headers with custom settings osC starts outputting text to the browser -- causes current HTTP headers to be sent osC outputs more text (HTML) to the browser Your problem: page started default PHP headers put in HTTP headers table osC PHP code started extraneous blank(s) in one or more files output as HTML text to browser -- causes current HTTP headers to be sent osC tries to update HTTP headers with custom settings -- error, headers already sent In general, the problem is that any text (including blanks) outside the <?php ... ?> gets sent directly to the browser as HTML text. If too early, before osC has updated the HTTP headers the way it wants, the headers will be shipped out too early. Read up on the subject of my advice 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 > Link to comment Share on other sites More sharing options...
MrPhil Posted December 20, 2009 Share Posted December 20, 2009 Read up on the subject of my advice Yes, I did read it, and I still disagree with your advice. It's not a good idea to get into the habit of leaving closing tags (?>) off, as XML will spew chunks all over the place (if you had read some of the followup, you would have seen that). Remember that XHTML is parsed through XML, so if you ever are using XHTML and omit closing tags, you could be in trouble. It's merely sloppy editing (blanks after ?>) that you're getting away with by omitting closing tags. There's no need for it. Link to comment Share on other sites More sharing options...
germ Posted December 20, 2009 Share Posted December 20, 2009 Yes, I did read it, and I still disagree with your advice. It's not a good idea to get into the habit of leaving closing tags (?>) off, as XML will spew chunks all over the place (if you had read some of the followup, you would have seen that). Remember that XHTML is parsed through XML, so if you ever are using XHTML and omit closing tags, you could be in trouble. It's merely sloppy editing (blanks after ?>) that you're getting away with by omitting closing tags. There's no need for it. Note: The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. They coded it that way to prevent the exact problem the OP was having. 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 > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.