douhao8456 2014-10-19 07:41
浏览 44
已采纳

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

I'm trying to insert received values into postgresql table using php. I can't figure out why this statement doesn't work

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

I get this error:

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

However, I tried this one:

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

It works, but it inserts all values into first column!

I'm not sure what I'm missing here!

  • 写回答

1条回答 默认 最新

  • dongxian6741 2014-10-19 07:43
    关注

    I think you are missing a whole host of single quotes in your VALUES list...

    $query = "INSERT INTO user_info (name, emailAddress, phoneNumber, jobDesc) VALUES ('" . $name . "','" . $emailAddr . "','" . $phoneNumber . "','" . $jobDesc ."')";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?