MySQL错误#1064,我不认为:该怎么办?

时间:2014-08-28 13:08:58

标签: php sql mariadb

MySQL error in file: /engine/modules/files/newfiles.php at line 14
Error Number: 1064
The Error returned was:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 5

SQL查询:

SELECT `id`, `title`, `version`, `alt_name` FROM `dle_` WHERE `approve` = '0' AND `date` < '2014-08-28 12:57:32' ORDER BY `date` DESC LIMIT 0,

代码片段:

 $db->query ( "SELECT `id`,
 `title`,
 `version`, 
 `alt_name`
 FROM `".PREFIX ."_".$modul_dbtitle ."` WHERE `approve` = '0' AND `date` < '{$thisdate}'  ORDER BY `date` DESC LIMIT 0,".$filesConfig ['numbernewfiles'] ."");

2 个答案:

答案 0 :(得分:1)

$modul_dbtitle显然没有值,因为您的表名在查询中不完整。

SELECT `id`, `title`, `version`, `alt_name` FROM `dle_` WHERE `approve` = '
                                                  ^^^^^^
                                                   HERE

你需要找出原因。我的猜测是你错过了变量名中的e

$modul_dbtitle

应该是

$module_dbtitle

此外,$filesConfig ['numbernewfiles']也不包含任何值,会破坏您的查询。

您应该确保error reporting is turned on因为我怀疑PHP会警告您这些错误。

答案 1 :(得分:0)

您的陈述中缺少行数:

LIMIT 0,".$filesConfig ['numbernewfiles']

DESC LIMIT 0,
           ^^^^^

看起来$filesConfig ['numbernewfiles']为空白