Re: periodic file writing error (fputs)
| From: | John W. Holmes | Date: | Thu, 05 Aug 2004 18:10:26 +0000 |
| Subject: | Re: periodic file writing error (fputs) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192922@lists.php.net to get a copy of this message | ||
From: "Sarah Gray" <sarah@fabled.net>
> Once a sale is completed a record is written to a log file on the
> server.
>
> $filename = $dir. "/". $logType."_".$today.".txt";
> $fp = fopen("$filename", "a+");
> fputs($fp, $logEntryStr);
> fclose($fp);
Consider this:
1. User A completes a transaction.
2. Script A reads the log file
3. User B completes a transaction
4. Script B read the log file
5. Script A write the new line to what was read in #2
6. Script B write the new line to what was read in #4
Now what's in the file? Only what Script B wrote.
http://us2.php.net/flock
---John Holmes...