Jump to content

New Line character


akkad

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/64041-new-line-character/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319218
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319230
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.