DLR Posted March 21, 2010 Share Posted March 21, 2010 I have developed a small programme on my laptop (Windows XP) and am running WAMP on it. My programmes run fine on the laptop but simply dont work on the shared server - a linux platform also running Apache. This simple programme outputs this error "Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/celciu/apps/test.php:1) in /usr/www/users/celciu/apps/test.php on line 2" <?php header("Location: CEL100.php"); ?> I have tried using ob_start(); but get the same error -just now says line 3 <?php ob_start(); header("Location: CEL100.php"); ob_end_flush(); ?> I am thoughrly confused. Any assistance would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/ Share on other sites More sharing options...
trq Posted March 21, 2010 Share Posted March 21, 2010 You should have been developing (and always should) in an environment that has error_reporting set high, and display errors switched on. This is likely the difference between the two environments in question as there is generally no difference (besides a few extensions) in php between Windows and Linux. Have you read the sticky regarding header errors? Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/#findComment-1029432 Share on other sites More sharing options...
DLR Posted March 21, 2010 Author Share Posted March 21, 2010 Thanks for the pointers, but 1. Have ready sticky, 2. Have searched forum before posting 3. Am developing with error reporting on (Not sure if it is set to "high" will check that 4. No white space - the code is only 3 lines including php tags! The code works in other files on same web address. So I must be doing something different here. I'm searching for my error - like "permissions". Any other pointrs would be appreciated. The main question is how can there be output if there is only "<?php" before the header? (and definately no whitespace either) And the offending line is line 1 - the php tag! Also why does the ob-start() not make a difference? I conclude that the environment must be different - but I cannot see what setting, or possibly ini setting I need to look at. Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/#findComment-1029440 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2010 Share Posted March 21, 2010 The main question is how can there be output if there is only "<?php" before the header? If there are no actual characters in the file before the <?php tag, then your file has been saved as a UTF-8 encoded file and the BOM (search if you don't know what that means) characters that your editor placed at that start of the file are the output that is preventing the header from working. Save your file either as an ANSI encoded file or if you must save it as a UTF-8 encoded file, save it without the BOM. If your editor does not have the option of saving a file using either of the suggested methods, you need to use a better programming editor. Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/#findComment-1029488 Share on other sites More sharing options...
sangoku Posted March 21, 2010 Share Posted March 21, 2010 O.o` Damn i am using utf-8 for my framework... i have to becouse of my language..... could you tell me if this file is Ok? >_< [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/#findComment-1029526 Share on other sites More sharing options...
DLR Posted March 21, 2010 Author Share Posted March 21, 2010 Thanks guys. Today has been a learning curve. I appreciate the time all of you have shared with me. The problem was that somehow I had filed this file in utf-8 - and you were correct it was the BOM(Byte order Mark - yes I did look it up aread quite a lot on it!) In passing I note you (PFMaBiSmAd) reccomend coding in ASCII - but I read that WW3 recommends and encourages utf-8 for HTML5. Would you share your motivation for recommending ASCII? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/#findComment-1029578 Share on other sites More sharing options...
PFMaBiSmAd Posted March 21, 2010 Share Posted March 21, 2010 I didn't recommend anything. I made an 'either' 'or' statement about the possible solutions to cover anything you might be doing since we don't have information from you about what it is you are doing. Quote Link to comment https://forums.phpfreaks.com/topic/195978-header-problems-migrating-from-development-on-windows-to-linux-server/#findComment-1029598 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.