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 ;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.