Home » questions » I want to use php to write and read a txt file to store scores from a Flash game. Is it reliable?

I want to use php to write and read a txt file to store scores from a Flash game. Is it reliable?

2006-08-04 00:01:02, Category: Programming & Design

Answers

  1. David G

    On 2006-08-04 00:05:23


    PHP is both stable and reliable, if your web-server supports it. If you're sending a url w/ parameters to pass to the PHP script for say, an online top-ten (addscore.php?ini=DAG&sco=50240, if a user ends the game with 50240 points and enters DAG as their initials), you must be aware that a user could manually enter that URL w/ their own parameters if they know of the PHP file's existance, and use it to either cheat their way into 1st place, etc., or put rude initials/names on the top-ten. Examples: addscore.php ? ini=DAG&sco=99999999999 addscore.php ? ini=FUK&sco=5555555 addscore.php ? ini=ASS&sco=5555555
  2. gruumsh

    On 2006-08-04 00:55:05


    Definitely you'll want to have a file-locking mechanism when dealing with the modification of text files. However, if you have the potential of a great number of simultaneous users, you're risking some of their browsers giving time-out errors before the lock gets freed -- not to mention PHP itself timing out -- that's a figure normally set on the server and cannot be changed if it's running in Safe Mode, and it may be considerably less than the typical 2-minute timeout for a browser's TCP/IP connection. And incidentally, yes, I've written Flash applications that communicate with a web server via PHP/MySQL. Normally I use the XML objects and parse the data via PHP's xml_parse_into_struct() function and then dynamically construct a MySQL query from the resulting arrays. So, in a nutshell, if there's any chance you're going to have high traffic, skip the text file and store your scores in a database. Typically if you're on a shared host that's got PHP, you've got MySQL as well. Even coding the application might be simpler, as you won't have to parse through the text file and deal with locking.
  3. jacinablackbox

    On 2006-08-04 00:05:36


    It should be reliable as long as you implement file locking correctly.