0
我有這樣的錯誤:這是MYSQL還是PHP錯誤?當mysql_fetch_array
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\lab\try.php on line 40
查詢是:
$graphquery = mysql_query ("SELECT
$cluster,
SUM(IF(idx=3,1,0)) AS green,
SUM(IF(idx=2,1,0)) AS yellow,
SUM(IF(idx=1,1,0)) AS red
FROM (SELECT
$cluster
$xcond
,LEAST(999 $acond) idx
FROM table
WHERE date >= '". $startDate ."'
AND date <= '". $endDate ."'
AND $regional = '$gregcond'
AND $latitude IS NOT NULL
GROUP BY $cluster, $lac, $mainid
HAVING $cluster IS NOT NULL
$paraxcond
) A
GROUP BY $cluster");
如果我回應查詢時,它會像這樣(沒有錯誤,完美的結果也BTW):
SELECT
cluster,
SUM(IF(idx=3,1,0)) AS green,
SUM(IF(idx=2,1,0)) AS yellow,
SUM(IF(idx=1,1,0)) AS red
FROM (SELECT
cluster,
ROUND(AVG(some_value_Index)) some_value_Index,
LEAST(999, AVG(some_value_Index)) idx
FROM TABLE
WHERE tanggal >= '2012-07-10'
AND tanggal <= '2012-08-02'
AND Regional = 'Regional_Example'
AND Latitude IS NOT NULL
GROUP BY cluster, Lac, ID
HAVING cluster IS NOT NULL
AND some_value_Index IN(3,2,1)) A
GROUP BY cluster
當我對腳本添加mysql_error,這聽起來像這樣:
Incorrect parameter count in the call to native function 'LEAST'
這裏是如何我願意用MySQL查詢:
$row = mysql_fetch_array ($graphquery)
當我回聲查詢並嘗試在SQLyog的或PHPMYADMIN有沒有包含錯誤,那麼誰能告訴我哪裏是請錯誤?
最新的$內容acond? – Hawili 2012-08-02 04:17:47
你不會告訴我們什麼是'$ graphquery',而你使用'mysql_',這更糟糕。開始使用'PDO'或'MySQLi'。 – alfasin 2012-08-02 04:23:49
$ acond和$ xcond只是一個條件bro,我認爲沒有什麼會影響腳本的。查詢太複雜,我想,所以我不能解釋更多的細節。但我會等待你的答案或另一個問題來清除它:)謝謝btw – 2012-08-02 04:23:58