Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 1 votes

Error in ALL page submits !


6 replies to this topic

#1 j2ee.freelancer

  • Community Member
  • 6 posts
  • Real Name:Freelancer

Posted 03 December 2009, 13:16

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.

Edited by j2ee.freelancer, 03 December 2009, 13:16.


#2 germ

  • Community Member
  • 13,584 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 03 December 2009, 17:58

View Postj2ee.freelancer, on 03 December 2009, 13:16, said:

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.

"Headers already sent" - The definitive help

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

SSL Implementation Help

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

#3 j2ee.freelancer

  • Community Member
  • 6 posts
  • Real Name:Freelancer

Posted 19 December 2009, 20:37

[This is superb !! But I could not get the logic behind. I removed the end tag and it worked !!
Thanks much.

#4 MrPhil

  • Community Member
  • 3,281 posts
  • Real Name:Phil
  • Gender:Male

Posted 19 December 2009, 21:01

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.

Edited by MrPhil, 19 December 2009, 21:03.


#5 germ

  • Community Member
  • 13,584 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 19 December 2009, 21:20

View PostMrPhil, on 19 December 2009, 21:01, said:

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.

"Headers already sent" - The definitive help

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

SSL Implementation Help

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

#6 MrPhil

  • Community Member
  • 3,281 posts
  • Real Name:Phil
  • Gender:Male

Posted 20 December 2009, 05:20

View Postgerm, on 19 December 2009, 21:20, said:

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.

#7 germ

  • Community Member
  • 13,584 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 20 December 2009, 14:15

View PostMrPhil, on 20 December 2009, 05:20, said:

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.

Quote

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.

"Headers already sent" - The definitive help

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

SSL Implementation Help

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