Maker Pro
Maker Pro

PHP Web Site Counter

HarryA

Jan 22, 2017
80
Joined
Jan 22, 2017
Messages
80
Greetings. I am trying to add a counter to a web page but it is not cooperating!

Directions are: place the count.php file and the hitcount.txt file on the server in the
same directory as the web page. hitcount.txt file should contain a value like zero.
For the include in the web page I use:

<div class="footnote">
<?php include‘count.php’; ?>
</div>

Things I have tried: change permissions on both files to 777. Change the web site
file extension to stml from html. I ran a install.php to install a forum on the server
last week so I know php files will run in my server space.
Could someone with knowledge of php please look at this? How to post code?

$filename = "hitcount.txt"; // This is at root of the file
[imath]contents = fread ([/imath]fd, filesize($filename)); // reading the content of the file
fclose ($fd); // Closing the file pointer
[imath]contents=[/imath]contents+1; // incrementing the counter value by one
echo $contents; // printing the incremented counter value

[imath]fp = fopen ([/imath]filename, "w"); // Open the file in write mode
fwrite ([imath]fp,[/imath]contents); // Write the new data to the file
fclose ($fp); // Closing the file pointer
 
Top