This is the source code from this tutorial on my blog.
- Click the download link at the top of the gist page to save these files to your machine.
- Unzip them and open
counter.php
and.htaccess
in your favorite non-Notepad text editor. - In counter.php, scroll down to the line that says
$link = mysqli_connect( ...
and change the parameters to the ones you use to connect to MySQL. - If your database doesn't use the UTF-8 charset, change the
UTF8
in theif (!mysqli_set_charset($link, "UTF8")) ...
line to the appropriate value. - Go down to the
if (!mysqli_select_db($link, "myrepodb")) ...
line and changemyrepodb
to the name of your database. - Run the
downloads.sql
file in your MySQL database, changingUTF8
if needed. In phpMyAdmin, you can use the import tab to do this. - Move your debs to a folder called
downloads
in your repo folder. - Open the
.htaccess
file and replacerepo
with the path to the folder that your repo is in, relative to your document root (usually htdocs or public_html) - Make 100,000% sure there is not a byte order mark at the start of counter.php. On Windows, open counter.php in Notepad++ and choose Convert to UTF-8 without BOM from the encoding menu. On Linux and Mac, pull up a terminal,
cd
to the folder the code is in and type:awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' counter.php > counter1.php && mv counter1.php counter.php
(note that this will cause problems if the file isn't in the UTF-8 charset) - Upload and enjoy :)