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 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)