drbi19093 2014-10-17 14:40
浏览 44
已采纳

您的SQL语法有错误 - 无法找到错误[关闭]

I seems to have a sytax error within my code but cannot see why.

the line in question is here:

mysqli_query($db,"INSERT INTO `horses` (`ParentID`,`Date`,`Track`,`Runners`, `Going`, `Distance`,`Class`,`Place`,`Losing_Dist`,`Stall`,`Horse`,`Weight`,`Trainer`,`Odds`,`Oddsmovement`,`Jockeys_Claim`,`Comments`,`Race_Name` )VALUES  ('$id ',' $Thedate','$thecourse','$noinrace','$going','$distance','$class','$place','$distance_bt','$stall','$horse','$weight','$thetrainer','$odds','$oddsmovement','$thejockey','$comments','$event')")or die(mysqli_error($db));

And the full error i get is here

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 'Meara ',' 22/1 ','25/1 < 22/1','D Nolan','',' Royal Marines ' at line 1

The line in which it says is near is this: '$thetrainer','$odds','$oddsmovement','$thejockey'

the database is set so all fields are varchat(250) aparent from parent id and id which are int

any further information please let me know

  • 写回答

1条回答 默认 最新

  • doupiao9318 2014-10-17 15:29
    关注

    This should work if the values in your PHP variables are valid:

    mysqli_query($db,"INSERT INTO horses (Date,Track,Runners,Going,Distance,Class,Place,Losing_Dist,Stall,Horse,Weight,Trainer,Odds,Oddsmovement,Jockeys_Claim,Comments,Race_Name) VALUES  ({$Thedate},{$thecourse},{$noinrace},{$going},{$distance},{$class},{$place},{$distance_bt},{$stall},{$horse},{$weight},{$thetrainer},{$odds},{$oddsmovement},{$thejockey},{$comments},{$event})")or die(mysqli_error($db));
    

    Like mentioned in the comments above if this is a public page you should protect again SQL injection there are several techniques just google it if you aren't sure how.

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

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置