通过php将值插入PostgreSQL表时出错

时间:2014-10-19 07:41:28

标签: php jquery postgresql

我正在尝试使用php将接收到的值插入到postgresql表中。我无法弄清楚为什么这个陈述不起作用

  $query = "INSERT INTO user_info (name, emailAddress, phoneNumber, jobDesc) VALUES ('" . $name . "," . $emailAddr . "," . $phoneNumber . "," . $jobDesc ."')";

我收到此错误:

Query failed: ERROR:  column "emailaddress" of relation "user_info" does not exist

然而,我试过这个:

$query = "INSERT INTO user_info VALUES ('" . $name . "," . $emailAddr . "," . $phoneNumber . "," . $jobDesc ."')";

它可以工作,但它会将所有值插入第一列!

我不确定我在这里缺少什么!

1 个答案:

答案 0 :(得分:1)

我认为您遗失了VALUES列表中的大量单引号...

$query = "INSERT INTO user_info (name, emailAddress, phoneNumber, jobDesc) VALUES ('" . $name . "','" . $emailAddr . "','" . $phoneNumber . "','" . $jobDesc ."')";