Author: (---.sttl.uswest.net)
Date: 06-09-03 21:55
Okay, I'm at school right now so I can't test this with my Flash file, but here is a PHP script I wrote. Since I don't know PHP, I am 153% certain I did something wrong. (Yes, 153% No more, no less.)
Here's the jest of it. I'm making a game that will save a replay of what the user has done (something like Starcraft), which anybody can watch. The replay will be a single string called "replayData". This replay will be saved to the server and be associated with their high score. As the high score list changes, new replays will appear and old replays will be removed. Hence, I need a unique ID for each replay that will be saved along with each high score, giving the appropriate reference to this replay. So here is what I came up with...
The flash script is sending the variable replaydata as a GET string.
Code:
<?php
// load replayData
$_GET["replayData"];
// Get the unique ID
$filename = "turret/unique.sco";
$file = fopen($filename, "w+");
if ($file == null)
{
fputs($file, 0);
}
// Create a file for the replay
$replay = fopen("turret/replay".$id.".rep", "w")
fputs($replay, $replayData);
fclose ($replay);
// return the ID to Flash
echo ($file);
// Increase the unique ID
$file++;
fputs($file, $file);
fclose($file);
?>
Since I don't know PHP at all (I mostly took clues from an existing file), I know I did something (or probably most things) wrong. Will someone please be kind enough to correct all my obscene errors? Many thanks.
|
|