RE: [PHP] voting using text files
Someone saw the value of turning the function you cite into error_log($msg, $type, $dest, $hdr) because it encapsulated a lot of features and approaches into one function. why not functions to initialize/reset polls, log votes, produce counts of votes, and stratify the vote choices (perhaps returning an array of counts of each choice), perhaps reducing the appended "choice" to a binary count (still one byte) of up to 255 choices? One of the real values of PHP is the robust list of such functions. Warren Vail Tools, Metrics & Quality Processes (415) 667-7814 Pager (877) 774-9891 215 Fremont 02-658 -Original Message- From: Scott Hurring [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 12:47 PM To: Php-General (E-mail) Subject: RE: [PHP] voting using text files file_append($file, $text); ?? --- Scott Hurring Systems Programmer EAC Corporation [EMAIL PROTECTED] Voice: 201-462-2149 Fax: 201-288-1515 > -Original Message- > From: Vail, Warren [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 22, 2002 3:46 PM > To: 'Rasmus Lerdorf'; 1LT John W. Holmes > Cc: Jason Soza; PHP-General > Subject: RE: [PHP] voting using text files > > > I see some real genious in this solution. This would be a > great function > addition to PHP, anybody? > > Warren Vail > Tools, Metrics & Quality Processes > (415) 667-7814 > Pager (877) 774-9891 > 215 Fremont 02-658 > > > -Original Message- > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 22, 2002 11:19 AM > To: 1LT John W. Holmes > Cc: Jason Soza; PHP-General > Subject: Re: [PHP] voting using text files > > > I think you guys are making this way more complicated than it > needs to be. > Anytime you start talking about locking files, you need to > apply a huge > reality check to yourself and sit down and approach the problem from a > different direction. > > In this case could I suggest that you make use of the fact > that appends of > less than a blocksize are atomic. Therefore, why not simply append a > single character to a text file for each vote? If you are > voting for a > list of things, assigning a character to each item and simply > append 'a', > 'b', 'c' or 'd' to your file. The size of the file instantly > gives you > the number of votes cast. Reading the file and counting the number of > times each letter occurs using something like substr_count() > will give you > the number of votes for each option. > > That gives you a lockless and flexible system without the > risk of deadlock > or missing votes due to race conditions. > > -Rasmus > > On Wed, 22 May 2002, 1LT John W. Holmes wrote: > > > > A good structure would be to have one file for each > possible answer and > > each > > > file contains the number of votes it has recieved. > > > Then: > > > --> Open file for the chosen option as read only > > > --> Read the value in the file > > > --> Close the file > > > --> Increase the value by one using ++ > > > --> Open the file again in write mode > > > --> Lock the file > > > --> Write the new value to the file - old one overwritten > > > --> Unlock the file > > > --> Close the file > > > > > > That's a bad method. You have to have the lock around the > read and the > > write. With your method, 5 users might read the file, all > getting 99 for > the > > count, and then each one will try to seperatly write 100 to > the file. So > you > > lose 4 actual counts. You want to open the file, read it, > update value, > > write it, unlock, and close the file. > > > > Using multiple files would just be a waste of space in my opinion. A > locked > > file doesn't stop the script, it simply waits for the file > to be unlocked > > and then continues on. > > > > ---John Holmes... > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] voting using text files
file_append($file, $text); ?? --- Scott Hurring Systems Programmer EAC Corporation [EMAIL PROTECTED] Voice: 201-462-2149 Fax: 201-288-1515 > -Original Message- > From: Vail, Warren [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 22, 2002 3:46 PM > To: 'Rasmus Lerdorf'; 1LT John W. Holmes > Cc: Jason Soza; PHP-General > Subject: RE: [PHP] voting using text files > > > I see some real genious in this solution. This would be a > great function > addition to PHP, anybody? > > Warren Vail > Tools, Metrics & Quality Processes > (415) 667-7814 > Pager (877) 774-9891 > 215 Fremont 02-658 > > > -Original Message- > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 22, 2002 11:19 AM > To: 1LT John W. Holmes > Cc: Jason Soza; PHP-General > Subject: Re: [PHP] voting using text files > > > I think you guys are making this way more complicated than it > needs to be. > Anytime you start talking about locking files, you need to > apply a huge > reality check to yourself and sit down and approach the problem from a > different direction. > > In this case could I suggest that you make use of the fact > that appends of > less than a blocksize are atomic. Therefore, why not simply append a > single character to a text file for each vote? If you are > voting for a > list of things, assigning a character to each item and simply > append 'a', > 'b', 'c' or 'd' to your file. The size of the file instantly > gives you > the number of votes cast. Reading the file and counting the number of > times each letter occurs using something like substr_count() > will give you > the number of votes for each option. > > That gives you a lockless and flexible system without the > risk of deadlock > or missing votes due to race conditions. > > -Rasmus > > On Wed, 22 May 2002, 1LT John W. Holmes wrote: > > > > A good structure would be to have one file for each > possible answer and > > each > > > file contains the number of votes it has recieved. > > > Then: > > > --> Open file for the chosen option as read only > > > --> Read the value in the file > > > --> Close the file > > > --> Increase the value by one using ++ > > > --> Open the file again in write mode > > > --> Lock the file > > > --> Write the new value to the file - old one overwritten > > > --> Unlock the file > > > --> Close the file > > > > > > That's a bad method. You have to have the lock around the > read and the > > write. With your method, 5 users might read the file, all > getting 99 for > the > > count, and then each one will try to seperatly write 100 to > the file. So > you > > lose 4 actual counts. You want to open the file, read it, > update value, > > write it, unlock, and close the file. > > > > Using multiple files would just be a waste of space in my opinion. A > locked > > file doesn't stop the script, it simply waits for the file > to be unlocked > > and then continues on. > > > > ---John Holmes... > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] voting using text files
I see some real genious in this solution. This would be a great function addition to PHP, anybody? Warren Vail Tools, Metrics & Quality Processes (415) 667-7814 Pager (877) 774-9891 215 Fremont 02-658 -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 11:19 AM To: 1LT John W. Holmes Cc: Jason Soza; PHP-General Subject: Re: [PHP] voting using text files I think you guys are making this way more complicated than it needs to be. Anytime you start talking about locking files, you need to apply a huge reality check to yourself and sit down and approach the problem from a different direction. In this case could I suggest that you make use of the fact that appends of less than a blocksize are atomic. Therefore, why not simply append a single character to a text file for each vote? If you are voting for a list of things, assigning a character to each item and simply append 'a', 'b', 'c' or 'd' to your file. The size of the file instantly gives you the number of votes cast. Reading the file and counting the number of times each letter occurs using something like substr_count() will give you the number of votes for each option. That gives you a lockless and flexible system without the risk of deadlock or missing votes due to race conditions. -Rasmus On Wed, 22 May 2002, 1LT John W. Holmes wrote: > > A good structure would be to have one file for each possible answer and > each > > file contains the number of votes it has recieved. > > Then: > > --> Open file for the chosen option as read only > > --> Read the value in the file > > --> Close the file > > --> Increase the value by one using ++ > > --> Open the file again in write mode > > --> Lock the file > > --> Write the new value to the file - old one overwritten > > --> Unlock the file > > --> Close the file > > > That's a bad method. You have to have the lock around the read and the > write. With your method, 5 users might read the file, all getting 99 for the > count, and then each one will try to seperatly write 100 to the file. So you > lose 4 actual counts. You want to open the file, read it, update value, > write it, unlock, and close the file. > > Using multiple files would just be a waste of space in my opinion. A locked > file doesn't stop the script, it simply waits for the file to be unlocked > and then continues on. > > ---John Holmes... > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
Well done that man! "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I think you guys are making this way more complicated than it needs to be. > Anytime you start talking about locking files, you need to apply a huge > reality check to yourself and sit down and approach the problem from a > different direction. > > In this case could I suggest that you make use of the fact that appends of > less than a blocksize are atomic. Therefore, why not simply append a > single character to a text file for each vote? If you are voting for a > list of things, assigning a character to each item and simply append 'a', > 'b', 'c' or 'd' to your file. The size of the file instantly gives you > the number of votes cast. Reading the file and counting the number of > times each letter occurs using something like substr_count() will give you > the number of votes for each option. > > That gives you a lockless and flexible system without the risk of deadlock > or missing votes due to race conditions. > > -Rasmus > > On Wed, 22 May 2002, 1LT John W. Holmes wrote: > > > > A good structure would be to have one file for each possible answer and > > each > > > file contains the number of votes it has recieved. > > > Then: > > > --> Open file for the chosen option as read only > > > --> Read the value in the file > > > --> Close the file > > > --> Increase the value by one using ++ > > > --> Open the file again in write mode > > > --> Lock the file > > > --> Write the new value to the file - old one overwritten > > > --> Unlock the file > > > --> Close the file > > > > > > That's a bad method. You have to have the lock around the read and the > > write. With your method, 5 users might read the file, all getting 99 for the > > count, and then each one will try to seperatly write 100 to the file. So you > > lose 4 actual counts. You want to open the file, read it, update value, > > write it, unlock, and close the file. > > > > Using multiple files would just be a waste of space in my opinion. A locked > > file doesn't stop the script, it simply waits for the file to be unlocked > > and then continues on. > > > > ---John Holmes... > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] voting using text files
Another consdieration with using files written to disk automatically. if there's any chance that the user could get some arbitrary value written to disk, then access the file thru the web-browser, it's a HUGE security risk. aside from all the file-locking and mucking about with permissions and maintaining the filesystem that Miguel mentioned. --- Scott Hurring Systems Programmer EAC Corporation [EMAIL PROTECTED] Voice: 201-462-2149 Fax: 201-288-1515 > -Original Message- > From: Jason Soza [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 22, 2002 3:26 PM > To: Miguel Cruz > Cc: PHP-General > Subject: Re: [PHP] voting using text files > > > And this is why I'm not an expert! > > I have a counter script on my page now that uses a flatfile to store > IP's, but it also stores a timestamp. When someone visits the > page, the > current time is compared to the stored timestamp for that IP > + whatever > timeout period I set. If it's less, then that IP is not > counted again. > If it's more, than the previous entry is deleted and a new > one written > with a new timestamp. I have it set for 15 minutes just to > keep people > from sitting and hitting 'reload' to run up my counter. > > Anyway, I figured the same type of thing could be used here, I just > didn't explain it. Seems that someone else came up with a simpler > solution anyhow! > > Thanks for pointing out my idea's flaws... I'm a little biased, so I > don't always see them myself. > > Jason Soza > > - Original Message - > From: Miguel Cruz <[EMAIL PROTECTED]> > Date: Wednesday, May 22, 2002 9:45 am > Subject: Re: [PHP] voting using text files > > > On Wed, 22 May 2002, Jason Soza wrote: > > > Using file locking, if two people tried to use the script at the > > same > > > time, wouldn't there be an error for one of them? > > > > The second session would just have to wait for the first to finish > > (which > > should be an infinitessimal amount of time). > > > > > My first guess at defeating this is having the script write a > > file named > > > after the voter's IP. Have the file written to a different > > directory for > > > whatever choices they have, then use readdir() to count the > > files in > > > each directory, i.e. the number of votes for each choice. Then > > if that > > > same IP tries to vote again, check it against votes already > > received and > > > approve/deny it. > > > > Using IPs is a pretty lousy way of uniquely identifying users, > > especially > > for a purpose like this: > > > > 1. If I dial in with a modem, I probably get a new IP each time I > > connect, > > so I can vote as often as I like. > > > > 2. Many companies, ISPs, and even countries use proxy servers that > > aggregate thousands or millions of users behind a handful of IP > > addresses. > > One vote from China, Saudi Arabia or New Zealand and that could be > > it for > > the country. Likewise AOL. > > > > Try cookies or something. Still can be defeated by the determined > > ballot-box stuffer, but so can everything else that doesn't > > require human > > verification of identity. > > > > miguel > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
And this is why I'm not an expert! I have a counter script on my page now that uses a flatfile to store IP's, but it also stores a timestamp. When someone visits the page, the current time is compared to the stored timestamp for that IP + whatever timeout period I set. If it's less, then that IP is not counted again. If it's more, than the previous entry is deleted and a new one written with a new timestamp. I have it set for 15 minutes just to keep people from sitting and hitting 'reload' to run up my counter. Anyway, I figured the same type of thing could be used here, I just didn't explain it. Seems that someone else came up with a simpler solution anyhow! Thanks for pointing out my idea's flaws... I'm a little biased, so I don't always see them myself. Jason Soza - Original Message - From: Miguel Cruz <[EMAIL PROTECTED]> Date: Wednesday, May 22, 2002 9:45 am Subject: Re: [PHP] voting using text files > On Wed, 22 May 2002, Jason Soza wrote: > > Using file locking, if two people tried to use the script at the > same > > time, wouldn't there be an error for one of them? > > The second session would just have to wait for the first to finish > (which > should be an infinitessimal amount of time). > > > My first guess at defeating this is having the script write a > file named > > after the voter's IP. Have the file written to a different > directory for > > whatever choices they have, then use readdir() to count the > files in > > each directory, i.e. the number of votes for each choice. Then > if that > > same IP tries to vote again, check it against votes already > received and > > approve/deny it. > > Using IPs is a pretty lousy way of uniquely identifying users, > especially > for a purpose like this: > > 1. If I dial in with a modem, I probably get a new IP each time I > connect, > so I can vote as often as I like. > > 2. Many companies, ISPs, and even countries use proxy servers that > aggregate thousands or millions of users behind a handful of IP > addresses. > One vote from China, Saudi Arabia or New Zealand and that could be > it for > the country. Likewise AOL. > > Try cookies or something. Still can be defeated by the determined > ballot-box stuffer, but so can everything else that doesn't > require human > verification of identity. > > miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Rasmus Lerdorf declared > I think you guys are making this way more complicated than it needs to be. > > In this case could I suggest that you make use of the fact that appends of > less than a blocksize are atomic. Therefore, why not simply append a > single character to a text file for each vote? If you are voting for a > list of things, assigning a character to each item and simply append 'a', > 'b', 'c' or 'd' to your file. The size of the file instantly gives you > the number of votes cast. Reading the file and counting the number of > times each letter occurs using something like substr_count() will give you > the number of votes for each option. > > That gives you a lockless and flexible system without the risk of deadlock > or missing votes due to race conditions. Ladies and gentelman, I think we have a winner, a very simple solution Rasmus, and more than adequate for my needs. Shame though, all the other file locking stuff looked like fun ;) Thanks everyone! - -- Nick Wilson // www.explodingnet.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE86+WuHpvrrTa6L5oRAgWVAJwJ8vOtpNCUaXd6Qm/gdkB407KXsQCfRSBt mL4lkx5YnYMAeO+ViTh1mo8= =1ht8 -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
I think you guys are making this way more complicated than it needs to be. Anytime you start talking about locking files, you need to apply a huge reality check to yourself and sit down and approach the problem from a different direction. In this case could I suggest that you make use of the fact that appends of less than a blocksize are atomic. Therefore, why not simply append a single character to a text file for each vote? If you are voting for a list of things, assigning a character to each item and simply append 'a', 'b', 'c' or 'd' to your file. The size of the file instantly gives you the number of votes cast. Reading the file and counting the number of times each letter occurs using something like substr_count() will give you the number of votes for each option. That gives you a lockless and flexible system without the risk of deadlock or missing votes due to race conditions. -Rasmus On Wed, 22 May 2002, 1LT John W. Holmes wrote: > > A good structure would be to have one file for each possible answer and > each > > file contains the number of votes it has recieved. > > Then: > > --> Open file for the chosen option as read only > > --> Read the value in the file > > --> Close the file > > --> Increase the value by one using ++ > > --> Open the file again in write mode > > --> Lock the file > > --> Write the new value to the file - old one overwritten > > --> Unlock the file > > --> Close the file > > > That's a bad method. You have to have the lock around the read and the > write. With your method, 5 users might read the file, all getting 99 for the > count, and then each one will try to seperatly write 100 to the file. So you > lose 4 actual counts. You want to open the file, read it, update value, > write it, unlock, and close the file. > > Using multiple files would just be a waste of space in my opinion. A locked > file doesn't stop the script, it simply waits for the file to be unlocked > and then continues on. > > ---John Holmes... > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
> A good structure would be to have one file for each possible answer and each > file contains the number of votes it has recieved. > Then: > --> Open file for the chosen option as read only > --> Read the value in the file > --> Close the file > --> Increase the value by one using ++ > --> Open the file again in write mode > --> Lock the file > --> Write the new value to the file - old one overwritten > --> Unlock the file > --> Close the file That's a bad method. You have to have the lock around the read and the write. With your method, 5 users might read the file, all getting 99 for the count, and then each one will try to seperatly write 100 to the file. So you lose 4 actual counts. You want to open the file, read it, update value, write it, unlock, and close the file. Using multiple files would just be a waste of space in my opinion. A locked file doesn't stop the script, it simply waits for the file to be unlocked and then continues on. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
On Wed, 22 May 2002, Jason Soza wrote: > Using file locking, if two people tried to use the script at the same > time, wouldn't there be an error for one of them? The second session would just have to wait for the first to finish (which should be an infinitessimal amount of time). > My first guess at defeating this is having the script write a file named > after the voter's IP. Have the file written to a different directory for > whatever choices they have, then use readdir() to count the files in > each directory, i.e. the number of votes for each choice. Then if that > same IP tries to vote again, check it against votes already received and > approve/deny it. Using IPs is a pretty lousy way of uniquely identifying users, especially for a purpose like this: 1. If I dial in with a modem, I probably get a new IP each time I connect, so I can vote as often as I like. 2. Many companies, ISPs, and even countries use proxy servers that aggregate thousands or millions of users behind a handful of IP addresses. One vote from China, Saudi Arabia or New Zealand and that could be it for the country. Likewise AOL. Try cookies or something. Still can be defeated by the determined ballot-box stuffer, but so can everything else that doesn't require human verification of identity. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
Nick: > I have to build a php 'survey' app. but cannot use a db, > clearly text files are the way but I wondered, before I start if any of > you have done similar and might offer any words of wisdom? Everyone thus far has recommended file locking. Another way is to create a new file for each vote, naming the new file with a date/time/microtime with each vote. You start or end the file name with something unique (a number or letter, etc) to each answer, OR, put the file in a particular directory depending on the answers. Then, it's easy to count how many people voted a particular way just by counting the number of files. For example, at a unix type command line, you can type "ls | wc -l" --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
Using file locking, if two people tried to use the script at the same time, wouldn't there be an error for one of them? My first guess at defeating this is having the script write a file named after the voter's IP. Have the file written to a different directory for whatever choices they have, then use readdir() to count the files in each directory, i.e. the number of votes for each choice. Then if that same IP tries to vote again, check it against votes already received and approve/deny it. I guess another way, have files written with consecutive titles, vote1, vote2, vote3, inside each one, store their vote choice, their IP, and a timestamp. I don't know, I'm not an expert! Just throwing out ideas. Jason Soza - Original Message - From: "1LT John W. Holmes" <[EMAIL PROTECTED]> Date: Wednesday, May 22, 2002 5:46 am Subject: Re: [PHP] voting using text files > Use file locking, so only one instance of the script is writing to > the file > at a time... > > www.php.net/flock > > ---John Holmes... > > - Original Message - > From: "Nick Wilson" <[EMAIL PROTECTED]> > To: "php-general" <[EMAIL PROTECTED]> > Sent: Wednesday, May 22, 2002 9:38 AM > Subject: [PHP] voting using text files > > > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > hi all > > I have to build a php 'survey' app. but cannot use a db, > > clearly text files are the way but I wondered, before I start if > any of > > you have done similar and might offer any words of wisdom? > > > > Are there any inherent problems I need be aware of for example > (I can > > already think of one: what if 2 people try to vote at the same > time?)> > > Just some general thoughts would be greatly appreciated ;) > > - -- > > Nick Wilson // www.explodingnet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
Just have a look around for a counter script which uses file locking, then port it to suit your needs, or check out the flock() example that *i think* there is in the manual. phpbuilder.com or zend.com or the rest are bound to have a script. Justin French on 22/05/02 11:38 PM, Nick Wilson ([EMAIL PROTECTED]) wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > hi all > I have to build a php 'survey' app. but cannot use a db, > clearly text files are the way but I wondered, before I start if any of > you have done similar and might offer any words of wisdom? > > Are there any inherent problems I need be aware of for example (I can > already think of one: what if 2 people try to vote at the same time?) > > Just some general thoughts would be greatly appreciated ;) > - -- > Nick Wilson // www.explodingnet.com > > > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.0.6 (GNU/Linux) > > iD8DBQE8659rHpvrrTa6L5oRAu8PAJ48Xf71iv98nN9nTac+tyHX5PJ+VgCgrTuI > dk/+Hf8S+L9NdBo02oDt25U= > =ESei > -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] voting using text files
Use file locking, so only one instance of the script is writing to the file at a time... www.php.net/flock ---John Holmes... - Original Message - From: "Nick Wilson" <[EMAIL PROTECTED]> To: "php-general" <[EMAIL PROTECTED]> Sent: Wednesday, May 22, 2002 9:38 AM Subject: [PHP] voting using text files > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > hi all > I have to build a php 'survey' app. but cannot use a db, > clearly text files are the way but I wondered, before I start if any of > you have done similar and might offer any words of wisdom? > > Are there any inherent problems I need be aware of for example (I can > already think of one: what if 2 people try to vote at the same time?) > > Just some general thoughts would be greatly appreciated ;) > - -- > Nick Wilson // www.explodingnet.com > > > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.0.6 (GNU/Linux) > > iD8DBQE8659rHpvrrTa6L5oRAu8PAJ48Xf71iv98nN9nTac+tyHX5PJ+VgCgrTuI > dk/+Hf8S+L9NdBo02oDt25U= > =ESei > -END PGP SIGNATURE- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php