ID: 15117
Comment by: [EMAIL PROTECTED]
Old Reported By: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Filesystem function related
Operating System: W2K
PHP Version: 4.1.1
New Comment:

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');


Previous Comments:
------------------------------------------------------------------------

[2002-01-20 06:26:27] [EMAIL PROTECTED]

It doesn't really matter with fopen() in append mode. It just opens the
file to append new data to the end of the file. What data will be
added, depents on when(?) and what(?)data the user submitted with the
form. Till that point it goes fine. But then there is this string with
same time mark being added to the file. Ofcourse multiple submitions
result in this same pattern being repeated over and over again.

------------------------------------------------------------------------

[2002-01-20 04:16:40] [EMAIL PROTECTED]

Are you sure the file is empty before the fopen() call?
See www.php.net/fopen for some more info...

------------------------------------------------------------------------

[2002-01-19 17:07:02] [EMAIL PROTECTED]


---- 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.

------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=15117&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to