xtoph Posted July 23, 2006 Share Posted July 23, 2006 hello. im new to php so bear with. i've created a simple hit counter for my personal website that opens a file log.txt and appends a line for each new hit on my opening page. but the newline isn't registering. it's all on one line.there are thousands of people who have had this problem previously, and they all solved it by using html breaks.that won't work for me because i want to use a text file. so does anyone know the reason this doesn't work?[code]fwrite($fh, "hit: ".$ip." ".$time_date."\n");[/code]ps. ive tried "\r" as wellusing php 5.0.4 Quote Link to comment https://forums.phpfreaks.com/topic/15389-newline-in-file-writing/ Share on other sites More sharing options...
wildteen88 Posted July 23, 2006 Share Posted July 23, 2006 What OS is your server?If its: - Windows use \r\n - Linux \n - Mac \rAlso the same applies with the OS you are viewing the log file in. Quote Link to comment https://forums.phpfreaks.com/topic/15389-newline-in-file-writing/#findComment-62379 Share on other sites More sharing options...
kenrbnsn Posted July 23, 2006 Share Posted July 23, 2006 The newline character is, unfortunately, tied to the OS your server is running on."\n" works on UNIX/Linux/VMS"\r\n" works on WindowsKen Quote Link to comment https://forums.phpfreaks.com/topic/15389-newline-in-file-writing/#findComment-62380 Share on other sites More sharing options...
xtoph Posted July 23, 2006 Author Share Posted July 23, 2006 aha.well php info claims that its a freeBSD machine. "\r\n" worked, so i dont care either way. much thanks. Quote Link to comment https://forums.phpfreaks.com/topic/15389-newline-in-file-writing/#findComment-62394 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.