however as the page is PHP, not SHTML, it doesn't seem to work as the server doesn't detect and run the cgi script. Help!
the issue is that the server hands the .php file over to the PHP pre-processor rather than the shtml processing engine, , and they are two entirely different languages.
Mix & match within the same document doesn't work, so you either need to use the shell_exec like Perturbatio suggested, or use a PHP counter instead. I would recommend getting the PHP counter -- they are very easy to write, and if you don't know how there are hundreds of samples available on the internet that will show you exactly what you would need to do... Google is your friend.