This question already has an answer here:
I have the following php code for a game I'm making. The if statement always fires true no matter what the scoreField or highScore equals.
$score = $_POST["scoreField"];
$savefile = fopen("SaveFile.txt", "r") or die("Unable to open file!");
$highScore = fread($savefile,filesize("SaveFile.txt"));
fclose($savefile);
if (intval($score) > intval($highscore)) {
$savingfile = fopen("SaveFile.txt", "w");
fwrite($savingfile, $score);
fclose($file);
}
I also found out that if I change the > to a < it always fires false. I have been unable to find any answers that work.
Aucun commentaire:
Enregistrer un commentaire