September 2nd, 1999, 02:36 PM
Here's what I want to do:
I want to put a .txt-file containing a number on my server and then read it out with a php-script which will display it on the html-page and higher the number by one.
PLEASE HELP ME!!!
send me all help to firstname.lastname@example.org
September 4th, 1999, 10:33 AM
Would you not just use fopen with the file name for reading the file and write back the number plus one.
The code below works, I would use a server side include to pull it into the HTML
(SSI in apache would be <!--#include file="readnum.php3"--> )
$fp=fopen("num.txt","r+"); // open file
$linein=fgets($fp,4096); // read first line = current number
$linein=intval($linein); // convert to integer
print "$linein"; // print it
$linein++; // increment by one
rewind($fp); // set pointer to start of file
fputs($fp,$linein); // write the number back to the file
fclose($fp); // close the file