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 ; Link to comment https://forums.phpfreaks.com/topic/194295-my-click-count-script-and-database-is-not-working-why/ 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.... Link to comment https://forums.phpfreaks.com/topic/194295-my-click-count-script-and-database-is-not-working-why/#findComment-1022158 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. Link to comment https://forums.phpfreaks.com/topic/194295-my-click-count-script-and-database-is-not-working-why/#findComment-1022159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.