2014-08-28 13 views
-1
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查詢:MySQL錯誤#1064,我不認爲:怎麼辦?

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'] .""); 
+0

請*不*不適用於您的問題使用標籤 – 2014-08-28 13:10:46

+0

LIMIT 0是沒有意義的刪除它 – Mihai 2014-08-28 13:12:13

+0

確保'numbernewfiles'列是一個'int',確實有一個值通過'$ filesConfig'傳遞。另外,如果你的列名確實是'numbernewfiles'而不是'Numbernewfiles' - 將錯誤報告添加到文件頂部 'error_reporting(E_ALL); ini_set('display_errors',1);' – 2014-08-28 13:31:56

回答

1

$modul_dbtitle顯然不具有價值的tablename是在查詢不完整的。

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

你需要弄清楚爲什麼。我的猜測是您在變量名失蹤的e

$modul_dbtitle 

應該

$module_dbtitle 

此外,$filesConfig ['numbernewfiles']還包含任何值,並會破壞你的查詢。

你應該確保error reporting is turned on,因爲我懷疑PHP會警告你這些錯誤。

+0

不,問題不在字母e ...需要其他變體。 – TheZimbabvEE 2014-08-28 13:31:03

+0

你的問題仍然是一樣的。該變量沒有價值。你需要弄清楚爲什麼。 – 2014-08-28 13:32:10

+0

'$ filesConfig'這是我們不知道的一個變量,或者它是如何從@TheZimbabvEE填充的請在您的問題中顯示模式代碼以及它是如何被帶入/提取的。 – 2014-08-28 13:32:58

0

有缺失行的數量在你的聲明:

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

DESC LIMIT 0, 
      ^^^^^ 

貌似$filesConfig ['numbernewfiles']是空白

+0

但錯誤不影響空變量...不是? – TheZimbabvEE 2014-08-28 13:33:05

+0

@TheZimbabvEE對不起,但我不明白你想要什麼。在'之後',你需要一個值。如果您添加一個,則語法正常。 – Jens 2014-08-28 13:37:12