hmm... There is an easier way you could go about this.
Create a file, call it count.php
Enter the following source, I recommend studying and asking about it so that its useful in the future:
$ecount = ("hits.txt");
$hits = file($ecount);
$count = intval(trim(file_get_contents($ecount)));
$count = $count + 1;
$fp = fopen($ecount , "w");
fputs($fp , "$count");
fclose($fp);
echo $count;
Now create a file called hits.txt, inside it write 0.
Now, on your index page, call the counter by using either code.
If your index ends in .php:
include('count.php');
Although if it ends in anything else:
<table><tr><td>Hits: <b>
<?php
include('count.php);
?>
</b></td></tr></table>
Best of luck!