|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-01-19 17:07 UTC] bitbybit at fibre dot a2000 dot nl
---- code ----
$orderstring = $date."\t". //current time
$tireqty." tires\t". //received form field
$oilqty." oil\t". //received form field
$sparkqty." sparks\t". //received form field
$totalamount."\t". /calc. from form fields
$address."\n"; //received form field
$fp = fopen("orders.txt", "a");
fwrite($fp, $orderstring);
fclose($fp);
---- output in orders.txt ----
22:32 19th Saturday 2002 4 tires 1 oil 12 sparks 503.80 NL
22:32 19th Saturday 2002 tires oil sparks 0.00
Bug:
When using fopen() in mode a or a+ the last line will be added without any obvious cause.
When fopen() is used in same code but in mode w it works correct like expected.
I haven't tested fopen() in all other available modes.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 07:00:01 2025 UTC |
Reproduced it. However, after the first two times, the same code stopped doing it (I only changed the string?). Seems to be semi-random at least, or something. Could it be a browser bug, having the page "accidentally" being submitted/reloaded? Temporary "fix" is to conditionally open it: if(!file_exists('orders.txt') || @file_size('orders.txt')==0) $fp = fopen('orders.txt', 'w'); else $fp = fopen('orders.txt', 'a');