神秘的 MySQL 错误“在第 1 行附近" [英] Mysterious MySQL error "near '' at line 1"

查看:67
本文介绍了神秘的 MySQL 错误“在第 1 行附近"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的错误信息:

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?

它从两个 PHP 文件返回了这条消息.以下是我在每个文件中进行的第一个 MySQL 查询:

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() );

在此之前有 PHP 代码可以打开数据库等

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

这里有一个类似的问题:链接

Here is a similar problem: Link

也许我的连接有误?

谢谢.

推荐答案

$currentId 为 null 或为空.并且不要忘记 SQL 注入!

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

这篇关于神秘的 MySQL 错误“在第 1 行附近"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆