xcoderx Posted April 26, 2010 Share Posted April 26, 2010 help please with this i get cannot modify header already sent in line 14 when i try to put some different code for language <?php $LangCode = (!empty($_GET['lang']))?$_GET['lang']:"en"; //include language file $LangFile = "lang/lang.".$LangCode.".php"; //ie lang.en.php if(file_exists($LangFile)) { include_once $LangFile; //echo some stuff }else{ header("Location: http://www.domain.com/redirect-to-new-page.php"); /* echo "Sorry there is no such language."; */ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/ Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 That error is caused by output being generated in your files before the call to header(). Check for ANY echoes, any whitespace or html outside your php tags as well. And also you should call die(); after the call to header(); Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/#findComment-1048907 Share on other sites More sharing options...
xcoderx Posted April 26, 2010 Author Share Posted April 26, 2010 see im placing this above <html> and inside body i got more <?php echo $array['1']; ?>'s so now what must i do? Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/#findComment-1048909 Share on other sites More sharing options...
Maq Posted April 26, 2010 Share Posted April 26, 2010 Please read this sticky: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/#findComment-1048912 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 If the output is after it's fine. But there is definitely output occurring somewhere even if it's a single space before <?php, Another problem is that the file MAY be encoded at utf-8 which by default has something called BOM at the start, which can't be seen, but is treated as output. If you have Notepad++ installed, you can change the encode type to ANSI or utf-8 without BOM. Other code editors may have a encode option also. Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/#findComment-1048914 Share on other sites More sharing options...
Mchl Posted April 26, 2010 Share Posted April 26, 2010 For starters you have three empty lines (that means three newline characters) before <?php Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/#findComment-1048929 Share on other sites More sharing options...
xcoderx Posted April 26, 2010 Author Share Posted April 26, 2010 only the language file i turned it to utf-8 and yes found the BOM  on lang files Quote Link to comment https://forums.phpfreaks.com/topic/199829-canot-midify-header/#findComment-1048950 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.