cxixer Posted June 22, 2010 Share Posted June 22, 2010 Hi, After getting the following type of error: Warning: Cannot modify header information - headers already sent by (output started at /home/cxixer/public_html/eliteinstallersupply/includes/languages/english/account_newsletters.php:47) in /home/cxixer/public_html/eliteinstallersupply/includes/functions/general.php on line 65 I searched, found the answer is to delete the white space, and go on with life. However, you have to do this on every freaking language file, why was it written like that in the first place if it causes problems? Don't get me wrong, I'm a great fan of oscommerce and have used and modified it for years, just have never had this problem. My old host never had a problem with white space. I am switching hosts. So now, with every new installation I have to spend an extra hour deleting unnecessary white space? My question is, is there an actual fix for this problem? Something in php.ini or on the host that maybe I can just flip a switch? It seems like if the problem occurred when I switched hosts, the problem is in the settings somewhere. If not, I am not dead set on this host, maybe I will try a different one - does godaddy have this problem? (For reference, old host = hostrocket, new host = hostgator). Please let me know. Link to comment Share on other sites More sharing options...
npn2531 Posted June 22, 2010 Share Posted June 22, 2010 One reason the problem is cropping up more often is a tightening of standards. As webhosts upgrade the php and other software on their systems, they can reach the point where the stuff like white space, and eventually other non-compliance with standards creates errors. One need for the upgrade is so that devices like cellphones and ipads can use the internet more efficiently. You maybe able to use a looser version of a doctype on your cart, or search for a webhost who hasn't upgraded their systems as vigorously. In the end, sooner or later, you'll just need to meet compliance standards. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120 Link to comment Share on other sites More sharing options...
MrPhil Posted June 22, 2010 Share Posted June 22, 2010 I searched, found the answer is to delete the white space, and go on with life. However, you have to do this on every freaking language file, why was it written like that in the first place if it causes problems? The "stock" osC does not have any extra whitespace in it. Obviously someone or something along the line mishandled your file(s) and added whitespace where there shouldn't be any. Did you ever save this particular file in an editor? Maybe you have a bad FTP client or server, or a badly designed editor, or just don't know how to use it properly (e.g., saving a file after browsing, rather than quitting). It's certainly possible that from time to time someone will botch a file edit and put it in the library for download, but it was not "written like that" in the first place. One reason the problem is cropping up more often is a tightening of standards. I disagree. I don't ever recall hearing about this, at least as a widespread problem. PHP and company have long barfed on extra whitespace outside of <?php...?>. By definition, outside of PHP code it is HTML and therefore is sent directly to the browser. When the first text of any kind is sent to the browser, whatever state the "headers" are in, they are sent too. At that point, if your code explicitly tries to send another header setting, it gets the error (it missed the train). It's not a problem of "tightening of standards", so looking around for out-of-date hosts isn't going to help. Link to comment Share on other sites More sharing options...
npn2531 Posted June 22, 2010 Share Posted June 22, 2010 Hi, After getting the following type of error: Warning: Cannot modify header information - headers already sent by (output started at /home/cxixer/public_html/eliteinstallersupply/includes/languages/english/account_newsletters.php:47) in /home/cxixer/public_html/eliteinstallersupply/includes/functions/general.php on line 65 I searched, found the answer is to delete the white space, and go on with life. However, you have to do this on every freaking language file, why was it written like that in the first place if it causes problems? Don't get me wrong, I'm a great fan of oscommerce and have used and modified it for years, just have never had this problem. My old host never had a problem with white space. I am switching hosts. So now, with every new installation I have to spend an extra hour deleting unnecessary white space? My question is, is there an actual fix for this problem? Something in php.ini or on the host that maybe I can just flip a switch? It seems like if the problem occurred when I switched hosts, the problem is in the settings somewhere. If not, I am not dead set on this host, maybe I will try a different one - does godaddy have this problem? (For reference, old host = hostrocket, new host = hostgator). Please let me know. Webhosts often upgrade their programming, or should be. They can upgrade PHP in increments, and if you are not having problems with one webhost, but switch to another and do have problems, then it could be they have tightened the screws on things to the point where whitespace yields an error. Again, sooner or later your old host, assuming it's not someone with a few servers in their garage, will upgrade to the point where it will catch the whitespace. So, yes, you have go through and remove it. Some web editors are cleverer than others, and it may be you can do it with some kind of text replace function. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120 Link to comment Share on other sites More sharing options...
MrPhil Posted June 23, 2010 Share Posted June 23, 2010 Whitespace outside of PHP code blocks <?php ... ?> has always been treated as HTML text and has always been sent directly to the browser and has always caused "headers already sent" problems. It is not a case of upgraded PHP versions "tightening the screws" on sloppy coding. No PHP implementations is going to "catch" extra whitespace and ignore it. Link to comment Share on other sites More sharing options...
cxixer Posted June 23, 2010 Author Share Posted June 23, 2010 OK, It could be standards, or not, but it is a difference between the two hosts. My code is heavily modified, but if it were something I was doing wrong - wouldn't it automatically screw up on BOTH hosts? To solve any errors, I use dreamweaver, edit the file, click upload. Is this a faulty process? If it is, then my fixing the code would have just kept screwing it up - because I fixed it in the same software, with the same process. I'm still confused by the white space causing an error. Of course everything outside the <?php ?> tags is treated as HTML - but there is plenty of white space in most HTML pages ... why doesn't that cause errors? Either way, I appreciate your input. Link to comment Share on other sites More sharing options...
cxixer Posted June 23, 2010 Author Share Posted June 23, 2010 For the record, both websites use the same version of PHP. Link to comment Share on other sites More sharing options...
npn2531 Posted June 23, 2010 Share Posted June 23, 2010 For the record, both websites use the same version of PHP. When a webhost upgrades software it can be incremental, and they can be 'upgrading' within versions, in little steps, so there might not be a change in version they list. But some little step they do might be just the step that causes them to handle whitespace ever so differently on your application. In the end whatever the cause, white space, as standards progress, becomes more of a problem. One way white space can get into a file is when you edit a file in some program, that program may double space stuff. For example when I use txt editor on my MAC to cut and paste to my ancient GOLIVE editor, everything gets double spaced, which has for me resulted in a couple of occasions in an extra line beneath a closing ?>. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120 Link to comment Share on other sites More sharing options...
MrPhil Posted June 23, 2010 Share Posted June 23, 2010 For the record, both websites use the same version of PHP. If you're getting a "headers already sent" error on one site and not the other, that means that there has been some difference in the handling of the PHP files. This resulted in one or more blanks, tabs, or end-of-lines immediately before the first <?php or after the last ?> in one or more files on one of the sites. To solve any errors, I use dreamweaver, edit the file, click upload. Is this a faulty process? Wellllllll... DW is not the editor of choice for editing PHP files. It's a "WYSIWYG" visual editor intended for laying out HTML pages. If you're very careful with it, it can be used as a text editor for PHP code, but that's kind of like scraping the paint off your house with a screwdriver -- the wrong tool for the job. I'm still confused by the white space causing an error. Of course everything outside the <?php ?> tags is treated as HTML - but there is plenty of white space in most HTML pages ... why doesn't that cause errors? The whitespace (blanks, tabs, newlines) causes problems only when it's in the wrong place. If your file is supposed to start out with PHP code, and you have a stray blank before the opening <?php, that blank is sent to the browser as text to be displayed. If the PHP code is supposed to output tags and text to the browser, no harm done. However, if it (or other files being called later) are still outputting "header" data (from the PHP header() function), there's a problem. Once the first byte of text/tags is requested to be sent (that stray blank), all the header information is flushed to the browser at that point, and no further header() calls are allowed. Read http://www.catskilltech.com/freeSW/SMF/faqs > "Cannot modify headers". Link to comment Share on other sites More sharing options...
npn2531 Posted June 23, 2010 Share Posted June 23, 2010 Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120 Link to comment Share on other sites More sharing options...
pablito21050 Posted July 3, 2010 Share Posted July 3, 2010 1000 THANKS to MrPhill and the others writers, I spent a day to find the problem and 10 minutes ago I found this precious thread. :lol: Yes the problem were some white lines after the closing tag (?>) ..at the end of the file, not on line that the warning says, anyway I deleted those lines and all working fine problem SOLVED, Thanks everybody. :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.