Freedom-n-Democrazy Posted September 26, 2011 Share Posted September 26, 2011 Does anyone know how I can make fwrite() write to a new line? I tried the following, but it didn't work. fwrite($fp, "".$_POST['feedback']."\n"); fwrite($fp, "".$_POST['feedback']."\r\n"); Link to comment https://forums.phpfreaks.com/topic/247871-writing-to-a-new-line-with-fwrite/ Share on other sites More sharing options...
codeprada Posted September 26, 2011 Share Posted September 26, 2011 What are you writing to? It should work according to those two lines of code you've posted. Link to comment https://forums.phpfreaks.com/topic/247871-writing-to-a-new-line-with-fwrite/#findComment-1272782 Share on other sites More sharing options...
Freedom-n-Democrazy Posted September 26, 2011 Author Share Posted September 26, 2011 Its just a simple HTML form. The data comes through alright, but the next post writes over the previous. I need a new line starting for each new post. Link to comment https://forums.phpfreaks.com/topic/247871-writing-to-a-new-line-with-fwrite/#findComment-1272786 Share on other sites More sharing options...
codeprada Posted September 26, 2011 Share Posted September 26, 2011 That's because you're using 'w' as the mode to which the file is opened. This overwrites what's in there. Use 'a' which means to append. Link to comment https://forums.phpfreaks.com/topic/247871-writing-to-a-new-line-with-fwrite/#findComment-1272788 Share on other sites More sharing options...
Freedom-n-Democrazy Posted September 26, 2011 Author Share Posted September 26, 2011 Ahhhh. Thanks man. Link to comment https://forums.phpfreaks.com/topic/247871-writing-to-a-new-line-with-fwrite/#findComment-1272789 Share on other sites More sharing options...
Freedom-n-Democrazy Posted September 26, 2011 Author Share Posted September 26, 2011 Whats the difference between \r and \n anyway? Link to comment https://forums.phpfreaks.com/topic/247871-writing-to-a-new-line-with-fwrite/#findComment-1272791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.