duan41497 2014-08-29 08:06
浏览 48
已采纳

预准备语句上的语法错误

I have this query

$q1 = "UPDATE klanten SET (
       kla_tel2,
       kla_mobiel,
       kla_fax,
       kla_btw_nummer,
       kla_bankrekening,
       kla_ww,
       kla_bez_straat,
       kla_bez_nummer,
       kla_bez_toev,
       kla_bez_pc,
       kla_bez_plaats,
       kla_bez_land_id,
       kla_post_straat,
       kla_post_nummer,
       kla_post_toev,
       kla_post_postbus,
       kla_post_pc,
       kla_post_plaats,
       kla_post_land_id,
       kla_fac_straat,
       kla_fac_nummer,
       kla_fac_toev,
       kla_fac_postbus
       kla_fac_pc,
       kla_fac_plaats,
       kla_fac_land_id,
       kla_sidn_owner,
       kla_reg_status,
       kla_rechtspersoon
       )
       VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
       WHERE kla_id=" . $kla_id;

But when executed it gives me a syntax error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( kla_tel2, kla_mobiel, kla_fax, kla_btw_num' at line 1: SQL: UPDATE klanten SET ...

What I know is that all values are filled and that $kla_id is filled too, but as this is a SQL Syntax error that shouldn't be a problem.

EDIT

MySql Client Version is 5.0.51a Server Version is 5.0.51a-24+lenny4 Protocol version is 10

  • 写回答

1条回答 默认 最新

  • dongzhang0418 2014-08-29 08:10
    关注

    You're using the wrong UPDATE syntax. Please see the docs for more info.

    The right syntax looks like:

    UPDATE klanten SET kla_tel2 = <some_value>, kla_mobiel = <some_other_value> WHERE kla_id = <some_third_value>
    

    You can also use this with prepared SQL statements like your example above, using question marks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?