Tom743
New Member
- Messages
- 72
- Reaction score
- 0
- Points
- 0
Basically, the average for the number of rolls on my script isn't working. It keeps going up, until it gets higher than 6 which is impossible because the numbers generated are between 1 and 6. I will +rep anyone who can help me
EDIT: I forgot to say- avarage.txt has the current average roll in, and roll.txt has the number of rolls made in it.
PHP:
<?php
$number = rand("1", "6");
$numberofroll = file_get_contents("roll.txt") + 1;
$average = file_get_contents("average.txt");
$averagevote = $average + $number / $numberofroll;
$file = "roll.txt";
$write = fopen($file, "w");
fwrite($write, $numberofroll);
fclose($write);
$file = "average.txt";
$write = fopen($file, "w");
fwrite($write, $averagevote);
fclose($write);
echo "You rolled {$number}. The average number is {$averagevote}";
?>
EDIT: I forgot to say- avarage.txt has the current average roll in, and roll.txt has the number of rolls made in it.
Last edited: