multible queries and gets() command
| From: | Jan-Mark Kunberger | Date: | Thu, 12 Jul 2001 14:43:14 +0000 |
| Subject: | multible queries and gets() command | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-57596@lists.php.net to get a copy of this message | ||
Dear php support !
Im 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);
fclose($fp);
}
else
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 dont 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
Jan
please write me a response to jan-mark.kunberger@web.de