Fluoresce Posted March 5, 2010 Share Posted March 5, 2010 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 ; Quote Link to comment Share on other sites More sharing options...
cags Posted March 5, 2010 Share Posted March 5, 2010 SET ccount = count+1 I'm fairly sure those two column names should match.... Quote Link to comment Share on other sites More sharing options...
Fluoresce Posted March 5, 2010 Author Share Posted March 5, 2010 Thank you, Cags! Problem solved in the space of a few minutes of posting in PHPFreaks.com. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.