New Line character & user computer name
Posted: Thu Aug 09, 2007 4:33 am
Everah | Please use
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
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi every body, in this code i am trying to write to file on linux server :Code: Select all
$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);
}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
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]