Jump to content

[SOLVED] Hit Counter


twilitegxa

Recommended Posts

I have this hit counter script, and it works fine, except for the part that is supposed to display the words, "You are visitor number" before the hits. Here is the code:

 

<?php
//Opening file to get counter value
$fp = fopen ("counter.txt", "r");
$count_number = fread ($fp, filesize ("counter.txt"));
fclose($fp);
?>
<html>
	<head>
		<title>Counter number</title>
	</head>
	<body>
	<?php
		$i="";
		$ImgPath="imgs/";	//Path of image folder
		$counter = (int)($count_number) + 1;
		$count_number = (string)($counter);
		$len = strlen($count_number);
		while($len!=$i && $len!=0)
		{
			echo "<img src=".$ImgPath.$count_number[$i].".jpg alt=\"You are visitor number $count_number\" width=20 Height=22>";
			$i++;
		}
		$fp = fopen ("counter.txt", "w");
		fwrite ($fp, $count_number);
		fclose($fp);
	?>
</body>
</html>

 

Can anyone tell me why it's not displaying?

Link to comment
https://forums.phpfreaks.com/topic/125858-solved-hit-counter/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.