Jump to content

My Click Count Script and Database is Not Working. Why?


Fluoresce

Recommended Posts

I have just written an ebook, which I want to distribute to get people to visit my Web site. I want to count the number of times people click on the link inside the ebook to get to my Web site.

 

The link in the ebook looks like this: www.mysite.com/visit-site.php

 

On visit-site.php, I have this PHP code:

 

<?php
$conn = mysql_connect('localhost','username', 'password') or trigger_error("SQL", E_USER_ERROR);
mysql_select_db('dbclickcount', $conn) or trigger_error("SQL", E_USER_ERROR);
mysql_query("UPDATE tclickcount SET ccount = count+1 WHERE id=1"); 
$href = "SELECT url FROM tclickcount WHERE id=1";
$qry = mysql_query($href);
list($href)=mysql_fetch_row($qry);
header("Location:$href");
mysql_close($conn);
?>

 

As you can see, visitors who click on the link inside the ebook go to visit-site.php, which is meant to log the click, before redirecting the visitor to my Web site. The problem is, visit-site.php is not logging the clicks; it's only redirecting the visitors. Anyone know why?

 

I created the database and table using PHPMyAdmin:

 

CREATE TABLE `dbclickcount`.`tclickcount` (
`id` TINYINT( 1 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`url` CHAR( 40 ) NOT NULL ,
`ccount` MEDIUMINT UNSIGNED NOT NULL
) ENGINE = MYISAM ;

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.