I think it's actually running into an error around here:
SET games='$games', for='$fornew',
What you can do is structure your code like this:
$query = "UPDATE tablename
SET games='$games', for='$fornew', agasint='$agasintnew'
WHERE teamid = '$team2id' ";
Then, when your sql error spits out, it will say "Line X" and then you have 3 lines to look at rather than one line with the error being anywhere.
~Brett