PHP更新查询语法错误

时间:2014-11-24 12:52:02

标签: mysql

任何人都可以告诉我为什么这不起作用,并返回语法错误吗?

$sql4 = "update apiStreetCheckGeneral 
         set (BBAverageSpeed, BBSuperFastBBAvailable, BBCommentary)
             values ('$averagespeed', '$superfast', '$bbcommentary') 
         where PostCode='".$values['PostCode']."'";
CustomQuery($sql4);

2 个答案:

答案 0 :(得分:1)

这是您的查询:

update apiStreetCheckGeneral set (BBAverageSpeed, BBSuperFastBBAvailable, BBCommentary)
     values ('$averagespeed', '$superfast', '$bbcommentary')
     where PostCode='".$values['PostCode'].

我不知道使用列列表或update的{​​{1}}语法。单独设置每个:

values

但是,您应该了解如何为update apiStreetCheckGeneral set BBAverageSpeed = '$averagespeed', BBSuperFastBBAvailable = '$superfast', BBCommentary = '$bbcommentary' where PostCode='".$values['PostCode']."'" 语句使用参数化查询,尤其是

答案 1 :(得分:0)

使用如下查询

$sql4 = "update apiStreetCheckGeneral 
         set BBAverageSpeed = '$averagespeed', 
          BBSuperFastBBAvailable = '$superfast', 
          BBCommentary = '$bbcommentary'
          where PostCode='".$values['PostCode']."' ";
CustomQuery($sql4);