我正在尝试使用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 ."')";
它可以工作,但它会将所有值插入第一列!
我不确定我在这里缺少什么!
答案 0 :(得分:1)
我认为您遗失了VALUES
列表中的大量单引号...
$query = "INSERT INTO user_info (name, emailAddress, phoneNumber, jobDesc) VALUES ('" . $name . "','" . $emailAddr . "','" . $phoneNumber . "','" . $jobDesc ."')";