Trying to make a very simple counter which updates the value in a mysql database table by 1 each time a user clicks on a link.
<a href='http://somesupersite.com' id='246' class='track'>My Link</a>
The javascript that should get the id and pass it to the php script:
$(document).ready(function(){
$('a.track').click(function() {
$.post('http://mysupersite.com/sys/tracker.php', {id:this.id});
});
});
The php script tracker.php should get the post variable and update the mysql database table column:
$id = $_POST['id'];
$con = mysqli_connect($mysqlHost, $mysqlUser, $mysqlPassword, $mysqlDatabase);
mysqli_query($con, "UPDATE table SET clicks = clicks + 1 WHERE id = $id");
I don't get any errors but the database does not update either.
Var_dumpyour query and run it intoPhpmyadminUPDATE table SET clicks = clicks + 1 WHERE id = $idwhat it print?