+3  A: 

You are enclosing the query in single quotes. And in single quotes variable interpolation(also called substitution) does not happen.

Simple example:

$who = 'harry potter';
echo 'hi "$who"'; // prints hi "$who"
echo "hi '$who'"; // prints hi 'harry potter'

Change your code as:

$test = $db->query("update games set played = played + 1 where id = '$gid'");

Also from the line: $gid = (int) stripslashes($_POST['id']); its clear that $gid is an integer and there is not need to enclose it in quotes in your query. So we have:

$test = $db->query("update games set played = played + 1 where id = $gid");
codaddict
`gid` is an INT; no need for quotes at all, but MySQL will implicitly convert a string into an INT if it doesn't fail the conversion.
OMG Ponies
Thank you so much!!! My other queries are in single quotes, but they don't have PHP variables in them.
Leticia Meyer
@OMG: Thanks for pointing.
codaddict
A: 

anything in single quotes is not parsed. do id="' . $gid . '"

alternatively wrap the entire thing in double quotes and put single quotes around $gid.

meder
+1  A: 
$test = $db->query("UPDATE `games` SET `played` = `played` + 1 WHERE `id` = '" . $gid . "'");
Alexander.Plutov
A: 

try

$test = $db->query
("
    UPDATE `games` 
    SET
       `played` = (`played` + 1)
    WHERE `id` ='" . $gid . "'
");
Lucian Vasile