Question

I have a php file which adds click track data to a .txt file. Problem is, each time data is added, it's added on the same line, even though I've added the "r\n":

<?php
    $src = isset($_GET['src']) ? $_GET['src'] : "-";
    $dst = isset($_GET['dst']) ? $_GET['dst'] : "-";
    $f = fopen('clickReport.txt',"a+");
    fwrite ($f, date('Y-m-d H:i'));
    fwrite ($f, " : " + $src + " : " + $dst + "\r\n");
    fclose($f);
?>

Text file output:

2014-02-05 01:1702014-02-05 01:1702014-02-05 01:1702014-02-05 01:170

Of course I would like it to be:

2014-02-05 01:170
2014-02-05 01:170
2014-02-05 01:170
2014-02-05 01:170

etc...

Was it helpful?

Solution

Try replacing this line:

fwrite ($f, " : " + $src + " : " + $dst + " _ " + "\r\n");

with this:

fwrite ($f," : ".$src." : ".$dst." _ "."\r\n");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top