pg_query():查询失败:错误:列“x”不存在第2行:SET名称= x

I have been working on something like a sign up form for a facebook app but instead of INSERT it UPDATE because before that I have already INSERT

$inserP = "INSERT INTO particular (id, name)
VALUES ($userid, 0)";
pg_query($conn, $inserP);

and I come across this error after submitting the form with the username tom:

pg_query(): Query failed: ERROR: column "tom" does not exist LINE 2: SET name=tom

Here is my form

<form action="update.php" method="post">
<input type="text" name="username" id="username" autocomplete="off" /> 
<input type="image" name="confirm" src="/images/confirm.png"/>
</form>

Here is my update.php

require('conn.php');
require('getfacebookapi.php');
$userid = idx($facebook->api('/me/'), 'id', string);
$username=$_POST['username'];
$pszz = "UPDATE particular
SET name=$username
WHERE id=$userid";
  if(preg_match("/^[a-zA-Z]+$/", $username)) {       
    pg_query($conn, $pszz);}

There is absolutely nothing wrong with my pg_pconnect.. Can someone tell me where I went wrong and how to fix this error? I'm new to both php and sql... Thanks!!

Never, never compose SQL statements by string concatenation or interpolation. Use bind parameters (PDO or at least pg_query_params).

You need to put quotes around your strings values, otherwise it will think it's a column. SET name='tom' WHERE id='someid'

name is a text field; inserting into text fields requires single-quotes around the value: 'tom'