php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34262 mutliple users cause write one but not another
Submitted: 2005-08-25 23:28 UTC Modified: 2005-08-25 23:38 UTC
From: hkncs06 at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2005-08-25 23:28 UTC] hkncs06 at gmail dot com
Description:
------------
NOT sure if this is a bug or program issue. If two people acess the file at the same time, would php write both of their information to the file or one will write to the file and the other doesn't not. With the code below, on the RequestLog.txt file, both of them on that file but only one on the TimeRequested.csv file. Why is this happened? Or this happen because someone is open the file (TimeRequested) while the other write to the file. Any help would be appreciate.

Reproduce code:
---------------
$flog = fopen("RequestLog.txt","a");
			fwrite($flog, $name);
			fwrite($flog, " submitted on ");
			fwrite($flog, $day);
			fwrite($flog, " at ");
			fwrite($flog, $time);
			fwrite($flog, "\n");
			fclose($flog);

			if(file_exists("TimeRequested.csv"))
			{
				writeToFile();
			}
			else
			{
				writeToFileHeader();
			}

Expected result:
----------------
All information of the two people access at the same time should be in the TimeRequested.csv file

Actual result:
--------------
Only one information write to the file.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-25 23:38 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

"a" means that you always append at the end of the file, this information is read upon opening and kept up to date during writing. Thus if you don't lock and both open at the same time the file will only contain the writes of the latter.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 01:01:27 2024 UTC