I am trying to get a value from a JavaScript variable and add it to a MySQL database using PHP, but my code does not seem to work. I know that this is a PHP forum, but it's kinda hard to ask this anywhere else.
This is my code where I actually pass the value (variable countForPHP) using XHR:
Here's how I get the value sent from the XHR:Code:xmlHttp.open("GET", "count.php?r=" + Math.random + "&count=" + countForPHP, async);
Does anyone know how to solve this problem?Code:$counter = $_GET["count"]; $pdo = new PDO('mysql:host=host;dbname=database;', 'username', 'password'); $sql = "UPDATE tbl_click SET click = click + ($counter)"; $pdo->exec($sql);


Reply With Quote

Bookmarks