Reading and writing to a text file
| From: | Ivan Quintero | Date: | Mon, 06 Nov 2000 05:27:50 +0000 |
| Subject: | Reading and writing to a text file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23844@lists.php.net to get a copy of this message | ||
I have problems writing a two digit number to a text file. Here is the code:
-- Begin Code ----
if (!$archivo = fopen("contador_banner.txt", "r+"))
{
echo "Error";
exit;
}
if (!$texto = fread ($archivo, 2))
{
echo "Error";
exit;
}
$texto = $texto + 1;
rewind ($archivo);
fputs ($archivo, $texto);
fclose ($archivo);
---- End of Code ----
I am writing a very rudimentary banner rotation program. This code snippet accomplishes one task: write a number that indicates the next banner to be displayed. This number is accumulated each time a banner is displayed.
Since the code above appends the number at the end of the file, I have problems when it comes to calculating two digit numbers. Among other things.
Thanks in advance.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at http://profiles.msn.com.