I have a users table where I want to update the scores each time a user finishes the game. Unityscript part is working fine but after I post the score to the database it appears doubled or tripled. I post the score as int and also the table column is of int format. My PHP looks like this:
$username = ($_POST['username']);
$score = ($_POST['score']);
try {
$db = new PDO("mysql:host=$host; dbname=$dbname", $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$statement = $db -> prepare ("UPDATE users SET score = score + $score
WHERE username = :username");
$statement->execute(array(':username' => $username));
}
catch(PDOException $e) {
echo $e->getMessage();
}
Any help or advice is appreciated.