![]() | | ||||||||
| | #1 |
| The Wandering Businessman War Room Member Join Date: Jan 2008 Location: The Globe
Posts: 1,209
Thanks: 142
Thanked 755 Times in 196 Posts
|
I'm working on a short script to write some information to a text file. First of all - here's the script. Code: $time = time();
$ip = $_SERVER['REMOTE_ADDR'];
$refer = $_SERVER['HTTP_REFERER'];
if ($refer == "") { $refer = "No Referrer available."; }
$write = "||$refer^$ip^$time";
$filename = "stats.txt";
if($flag == false) { // if the file doesn't exist
$handle = fopen($filename, 'w') or die("can't open file");
fwrite($handle, $write);
fclose($handle);
} else { //if the file already exists
//write to file
$handle = fopen($filename, 'a') or die("can't open file");
fwrite($handle, $write);
fclose($handle);
} Gather information -> Does the file already exist? -> (No) Create empty file (Yes) Append gathered information to the end of the file Can anyone see where this is going wonky? I'm not seeing it here and have a feeling the script is being called twice somehow. |
| | |
| | |
| | #2 |
| The Wandering Businessman War Room Member Join Date: Jan 2008 Location: The Globe
Posts: 1,209
Thanks: 142
Thanked 755 Times in 196 Posts
|
Nevermind. I figured it out right after I posted. It was being called twice.
|
| | |
| | |
![]() |
|
| Tags |
| debug, php, script |
| Thread Tools | |
| |
![]() |