akkad Posted August 9, 2007 Share Posted August 9, 2007 Hi every body, in this code i am trying to write to file on linux server : <code> $c=$_SERVER['HTTP_HOST']; echo $_SERVER['REMOTE_PORT']; $ip_add=$c; $today=date("d-M-y"); $date = date("Y-M-d H:i:s"); $logfile = $today."_log.txt"; $dir = 'log'; $saveLocation=$dir . '/' . $logfile; $logMessage=$ip_add; if(!is_dir($dir)) { mkdir($dir,"0755"); } if (!$handle = fopen($saveLocation, "a")) { //ERROR, DO SOMETHING #echo "can't create the file"; exit; } else { if(fwrite($handle,'Date: '.$date. ' IP: '. $logMessage.' '.'/r/n')===FALSE) { //ERROR, DO SOMETHING # echo " can't write to the file "; exit; } fclose($handle); } </code> 1. how to go to new line each time we are writting in the file (/r/n it is not working, it is writing it in the file as /r/n) like this: Date: 2007-Aug-09 09:12:36 IP: 10.6.0.15 /r/n 2. can i write the user computer name in the file and its port. coz i want to create a log file for each user loggin into the system Quote Link to comment https://forums.phpfreaks.com/topic/64041-new-line-character/ Share on other sites More sharing options...
phpknight Posted August 9, 2007 Share Posted August 9, 2007 Are you sure it is not \r\n? Quote Link to comment https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319207 Share on other sites More sharing options...
akkad Posted August 9, 2007 Author Share Posted August 9, 2007 i am sure of what i am seeing , look what is writting into the file when i am trying both : \r\n and /r/n: Date: 2007-Aug-09 09:51:52 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 09:55:17 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 09:57:04 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 09:57:51 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 10:00:54 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 10:01:12 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 10:03:25 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 10:04:22 IP: 10.6.0.15 /r/nDate: 2007-Aug-09 10:07:11 IP: 10.6.0.15 \r\n Quote Link to comment https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319218 Share on other sites More sharing options...
Daniel0 Posted August 9, 2007 Share Posted August 9, 2007 It's \r\n and it must be in double quotes... See: http://php.net/string Edit: Please use tags... Quote Link to comment https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319223 Share on other sites More sharing options...
akkad Posted August 9, 2007 Author Share Posted August 9, 2007 you are right "\r\n" but i want to know the answer of second question: 1.how to get the user computer name , and i have another question also : 2. after submitting a forum , is there a way that i will refresh another frame not the frame mentioned in the action attribute in the form tag. i meant suppose i have 3 frames : first frame :top.php which contatins the form second frame: body.php which recieve the form contents third frame : left.php contains some links in the body.php so how can i , after submitting the form refresh both body.php and left.php Quote Link to comment https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319230 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.