Reading and writing to a php file

I am trying to make 2 commands, one which will read from a php file, and one which edits the variables being read, getting nightbot to read from the file is easy but I cant make edited variables permanent, every time it adds 1 to the var which starts at 0, and nightbot says in chat “1” but the next time I run the command I want nightbot to say “2” but it still says “1”. i cant just use the inbuilt count function because the command will read many different variables and return them all.
This is what i have currently for testing (doesnt include the 9 other variables, just the first one “bow”)

<?php

$one = 1;
$bow = 0;
if(isset($_GET[‘query’]))
{
$strQuery = strtolower(trim(urldecode($_GET[‘query’])));
switch($strQuery)
{
case ‘bow’:
$bow = $bow + $one;
echo $bow;
break;

}

}
?>

Hiya, you will have to store that counter data somewhere, database, file or whatever. If you set $bow hardcoded to 0 and $one to 1, it will always be 0+1.

how would i store it in a different file?

Thats up to you, use the PHP functions to store the value the way you like.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.