dongxing2015 2012-01-18 03:47
浏览 239
已采纳

神秘的MySQL错误“靠近''在第1行”

Full error message:

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 '' at line 1

So it hasn't really told me much... Is there a way to find out more?

It has returned this message from two PHP files. Here are the first MySQL queries that I made in each file:

$query = mysql_query("SELECT * FROM `questions` WHERE `id`=".$currentId.";") or die( mysql_error() );

$query = mysql_query("SELECT * FROM `questions` WHERE `id`=".$theNextId.";") or die( mysql_error() );

There is PHP code before this though which opens the database etc.

Here is a similar problem: Link

Perhaps there an error in my concatenation?

Thanks.

  • 写回答

3条回答 默认 最新

  • drsb77336 2012-01-18 03:55
    关注

    $currentId is null or empty. And don't forget about SQL-injection!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流