Perfidus Posted November 25, 2009 Share Posted November 25, 2009 I'm not doing anything special, I have just copied the code from the php manual and substituted the 'a' in fwrite for 'w' all I'm trying to do is to write write to a xml file. The problem is that I can only write 3 characters, in this case: "Com" $filename = 'myfolder/data.xml'; $somecontent = 'Come on write some stuff'; if (is_writable($filename)) { if (!$handle = fopen($filename, 'w')) { echo "Problem opening file"; exit; } if (fwrite($handle, $somecontent) === FALSE) { echo "Problem writing to file"; exit; } echo "The file have been written"; fclose($handle); } else { echo "Impossible to read the file"; } Quote Link to comment https://forums.phpfreaks.com/topic/182960-problem-with-fwrite/ Share on other sites More sharing options...
RussellReal Posted November 26, 2009 Share Posted November 26, 2009 there should be no problem with your code.. Quote Link to comment https://forums.phpfreaks.com/topic/182960-problem-with-fwrite/#findComment-965856 Share on other sites More sharing options...
Perfidus Posted November 26, 2009 Author Share Posted November 26, 2009 But it is writing only 3 chars!! What should it be? Somethin with the encoding (it is a utf8 file)? The chmod at the directory? Quote Link to comment https://forums.phpfreaks.com/topic/182960-problem-with-fwrite/#findComment-965874 Share on other sites More sharing options...
premiso Posted November 26, 2009 Share Posted November 26, 2009 Just tested the code as is, it worked just fine. Try adding the length to the fwrite and set it to 1048 and maybe that will help. If it does, there is probably a setting on your server somewhere that was causing the issue. Quote Link to comment https://forums.phpfreaks.com/topic/182960-problem-with-fwrite/#findComment-965970 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.