Originally posted by La Parka
I'm looking to change it in the way that most forum install scripts alter DB connection variables located in a config.php file.
Considering that a PHP script is just a text file, there's nothing stopping you from reading it, finding the statement that sets the variable (since you're controlling how the page is written in the first place you can make this step easy enough), and then rewrite the script, inserting the new value of the variable.
If you only set $currentnumber once in one line of the script:
preg_match('/\$currentnumber = (\\d+);/', $script, $match);
$script = preg_replace('/\$currentnumber = (\\d+);/',
'$currentnumber = '.($match[1]+1).';',
$script);
Once you've done all that (and I've actually avoided turning it into a one-liner, which I could have done), it's a matter of writing out the $script file again.
You could look at those forum install scripts see how they do it.