Jadd Posted August 27, 2009 Share Posted August 27, 2009 Hello users of phpfreaks! I was just wondering why this code doesn't work: <?php $File = fopen("banned.dat", 'a+'); $IP = $_SERVER['REMOTE_ADDR']; fwrite($File, $IP."\n"); fclose($File); ?> It's a banning mechanism I use in a program I made, if anyone tries to decompile it, but for some reason when it writes to the 'banned.dat' file it appears as '123.456.78.901n' instead of making a new line entirely. Any ideas? Thanks, Jadd. Link to comment https://forums.phpfreaks.com/topic/172091-solved-n-line-not-working/ Share on other sites More sharing options...
Bricktop Posted August 27, 2009 Share Posted August 27, 2009 Hi Jadd, Change: fwrite($File, $IP."\n"); to: fwrite($File, $IP."\r\n"); Link to comment https://forums.phpfreaks.com/topic/172091-solved-n-line-not-working/#findComment-907353 Share on other sites More sharing options...
Jadd Posted August 27, 2009 Author Share Posted August 27, 2009 Hi Jadd, Change: fwrite($File, $IP."\n"); to: fwrite($File, $IP."\r\n"); Now I get 123.456.78.901rn... Possibly something wrong with my webhost? Link to comment https://forums.phpfreaks.com/topic/172091-solved-n-line-not-working/#findComment-907359 Share on other sites More sharing options...
trq Posted August 27, 2009 Share Posted August 27, 2009 Is that your exact code? Link to comment https://forums.phpfreaks.com/topic/172091-solved-n-line-not-working/#findComment-907362 Share on other sites More sharing options...
Bricktop Posted August 27, 2009 Share Posted August 27, 2009 Give PHP_EOL a go. fwrite($File, $IP. PHP_EOL); But your code should be working as it is, not sure why it isn't - like thorpe said, is that your exact code? Link to comment https://forums.phpfreaks.com/topic/172091-solved-n-line-not-working/#findComment-907363 Share on other sites More sharing options...
Jadd Posted August 27, 2009 Author Share Posted August 27, 2009 Give PHP_EOL a go. fwrite($File, $IP. PHP_EOL); But your code should be working as it is, not sure why it isn't - like thorpe said, is that your exact code? Yep, that was my exact code. Doesn't matter though, that PHP_EOL command worked, thanks a bunch Link to comment https://forums.phpfreaks.com/topic/172091-solved-n-line-not-working/#findComment-907368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.