To verify what went wrong just print the
$sql
string and check if it is a valid SQL command.
The error is probably sourced by the missing space before the
WHERE
keyword. So change that to
$sql ="Update ".$table." SET ".$values." WHERE id=:id";
Other possible error sources are that one or more of your
$keys
contains a comma or space.