1. Computing

PHP Flat File Counter

By , About.com Guide

1 of 4

Create The Count File
In our previous tutorial we show you how to create a simple website counter using PHP and MySQL. Not everyone has access to MySQL, or wants to use it. We can also create a simple counter with just PHP, using a flat file to store our count.

Create a file, containing just the number 0 (or whatever number you want to start your count at) and save it as counter.txt. Upload it to your server, and CHMOD it to 777. The contents of the file will just be 0, it will look like this:

 0
It is very important to set the permissions to 777, or we won't be able to update the count when new people visit the site.
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Step By Steps
  5. PHP Flat File Counter - PHP Counter No MySQL - PHP Count Text File

©2013 About.com. All rights reserved.