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

通过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 ."')";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 状态机/汽车转向灯/Sateflow
  • ¥15 这个有点复杂 有没有人看看
  • ¥15 用python如何确定子孙元素在父元素中的位置
  • ¥15 obj文件滤除异常高程
  • ¥15 用mathematicas或者matlab计算三重积分
  • ¥15 Loop unrolling的runtime计算
  • ¥100 NVMe-oF的Target端,开启attr_offload后,测试失败。
  • ¥100 有偿照片马赛克去掉,保留原始数据
  • ¥15 c# winform http报错,如何解决?
  • ¥15 统计软件及应用-r软件