Help with query

hi i have the query below…when i test it in phpmyadmin with the variables it works, but it’s not working in my script. I output the variable $cid and it is passing ‘All’. i’m trying to display all records that match the criterias below. when i remove $cid==‘All’ then all the records come up, but when i add in $cid==‘All’ then no results are returned.


($done=='1' && $statid=='All' && $tid=='All' && $assignto=='All' && $cid=='All')
 { 
$query = "SELECT m.id, DATE_FORMAT(m.mdate,'%m/%d/%Y') as mdate, TIME_FORMAT(m.mdate,'%r') as time, m.lid, m.item,   m.description, m.status, DATE_FORMAT(m.date_complete,'%m/%d/%Y'), a.assign, c.cost, w.assignto, w.start, w.finish, p.category, TIME_TO_SEC(w.finish) - TIME_TO_SEC(w.start) AS elapsetime, DATE_FORMAT(w.wdate,'%m/%d/%Y') as wdate,     s.sid, s.serviceby, l.descr 
	      FROM maint m 
		  left join assign a on m.aid=a.aid 
		  left join cost c on m.id=c.mid 
		  left join category p on m.cid=p.cid 
		  left join workassign w on w.mid=m.id 
		  left join service s on s.sid=w.assignto 
		  left join location l on l.location=m.lid
		  WHERE m.date_complete >= '$StartDate' AND m.date_complete <= '$EndDate'
		  AND m.lid IN ('$lid') 
		  AND (m.item LIKE '%$search%' OR m.description LIKE '%$search%')
		  ORDER BY m.lid ";
	$result = mysql_query($query) or die ("Could not run the query3: " . mysql_error());
	
}

Echo your $query variable, post the query back here. It’s hard to assume what went wrong when we don’t have the whole picture. Also, post any errors that you get, if you get them.

says: Could not run the query: Query was empty

sorry here it is: SELECT m.id, DATE_FORMAT(m.mdate,‘%m/%d/%Y’) as mdate, TIME_FORMAT(m.mdate,‘%r’) as time, m.lid, m.item, m.description, m.status, DATE_FORMAT(m.date_complete,‘%m/%d/%Y’), a.assign, c.cost, w.assignto, w.start, w.finish, p.category, TIME_TO_SEC(w.finish) - TIME_TO_SEC(w.start) AS elapsetime, DATE_FORMAT(w.wdate,‘%m/%d/%Y’) as wdate, s.sid, s.serviceby, l.descr FROM maint m left join assign a on m.aid=a.aid left join cost c on m.id=c.mid left join category p on m.cid=p.cid left join workassign w on w.mid=m.id left join service s on s.sid=w.assignto left join location l on l.location=m.lid WHERE m.date_complete >= ‘2011-01-21’ AND m.date_complete <= ‘2011-01-27’ AND m.lid IN (‘309’,‘310’,‘320’,‘322’,‘323’,‘324’,‘328’,‘329’,‘330’,‘331’,‘332’,‘334’,‘335’,‘336’,‘337’,‘338’,‘339’,‘340’,‘341’,‘348’,‘356’,‘359’,‘360’,‘367’,‘401’,‘402’,‘403’,‘404’,‘406’,‘408’,‘410’,‘411’,‘412’,‘413’,‘414’,‘415’,‘431’,‘450’,‘451’,‘453’,‘455’,‘456’,‘458’,‘459’,‘460’,‘461’,‘465’,‘466’,‘467’,‘468’,‘469’,‘470’,‘471’,‘474’,‘475’,‘476’,‘477’,‘480’,‘602’,‘607’,‘641’,‘650’,‘651’,‘653’,‘900’,‘901’,‘912’,‘918’,‘919’,‘948’,‘964’,‘977’,‘Albany St’,‘Leete St’,‘MainOffice’,‘Misc’,‘Other’,‘RetailShop’,‘Seth’) AND (m.item LIKE ‘%%’ OR m.description LIKE ‘%%’) ORDER BY m.lid