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 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络
  • ¥66 关于川崎机器人调速问题
  • ¥15 winFrom界面无法打开
  • ¥30 crossover21 ARM64版本安装软件问题
  • ¥15 mymetaobjecthandler没有进入
  • ¥15 mmo能不能做客户端怪物
  • ¥15 osm下载到arcgis出错
  • ¥15 Dell g15 每次打开eiq portal后3分钟内自动退出
  • ¥200 使用python编写程序,采用socket方式获取网页实时刷新的数据,能定时print()出来就行。