I don't know how to fix the problem, but I would strongly recommend not using shtml - set up a small PHP script to do exactly this, it'll be far easier.
If you don't know PHP too well, you could use http://www.phpjunkyard.com/php-graphical-hit-counter.php
Actually, that would solve the problem...