I currently have a text file that has a number in it, i need to know how i can add 1 to the value of that number, save it and then display the value in the browser. To make it more easy to understand... lets say I have a text file called "number.txt". this text file contains the following number "234", now basically what i need a code to do is add 1 to that number and save it, so in this case the "number.txt" wll now have a value of "235" and finally i need to display the final number on the browser.
Any help would be appreciated.
Cheers
Linda
You will have to do some cgi scripting for this, server side include would be a good mechanism for pulling the result into your page.
Personally I would use a database for this sort of thing otherwise file corruption could occur if the file was being accessed by mutliple pages.
What scripting language will you use?
I have one question though. incywincy mentioned that file corruption could occur if the file was being accessed by mutliple pages. what does he mean by that? if multiple users were view the data from that text file at the same time, could the file get corrupted? or is it if multiple users were trying to write to the file at the same time?
Cheers
Linda
-------------------- put this in html document
<!--#include virtual="/path/to/above/script.cgi" -->
NOTE:
believe incywincy, the above will get corrupted with many visitors or if page is accessed by more than one at the same exact time. There is no file locking on *nix machines. You must use a flock [search.cpan.org] to keep this from happening, but no always installed/available. You can make your own if flock not available. Just open a file for writing at the start of the script, just before that, check if the file exsists, loop/pause/quit if exsists, delete this file at the end...basically
try changing the '>' to '+<':
open(FILE,"+<$file");
---------------
lindajames, you can have as many people reading a file without concerns, just when you write to them do you need to make sure you are the only one doing it at this time kinda thing...
Cheers
Linda