I have an error like this :
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\lab\try.php on line 40
The query is :
$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");
If I echo the query, it will be like this (no error, perfect result too 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
When I add mysql_error on that script, it sounds like this :
Incorrect parameter count in the call to native function 'LEAST'
And here is how I willing to use the MYSQL Query :
$row = mysql_fetch_array ($graphquery)
When I am ECHO the query and try it on SQLYOG or PHPMYADMIN there is no error contained, so Can anyone tell me where is the error please?