Dear php support !

Iím using the fgets() command in a counter. Basically the counter opens
a txt-file gets the information from the previous query (see code
below). Later this information will be evaluated and be written back
into the txt-file (this is not in the code below).

$fn = "qrydata.txt";
   if (file_exists($fn))
      /* alte Zahl lesen */
      $fp = fopen($fn,"r");
      $zahl = fgets($fp,10);
      $date = fgets($fp,40);

If there are only a few queries this code works fine.
In the last weeks I had a sharp increase in queries and the script will
be called several times between getting the strings from the txt-file
and writing a new string back to the txt-file.
The gets() method is not only copying the lines out of the txt-file. It
actually deletes them out of the txt-file.

If a second query opens the file before the new string is written back
into the txt-file, the variables are either empty or contain only a part
of the string.

I donít want to lock the file since this would enlarge the query time.
Is there a command which copies only the strings out of the txt-file
(without deleting it) ?
Or do you have another idea to solve this problem ?

Thank you very much for your help


please write me a response to [EMAIL PROTECTED]

PHP General Mailing List (
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