You have the group by and where clauses in the wrong order.
SELECT search_engine, COUNT(*) as num
FROM search_engine_log
WHERE when => '$startDate' and when <= '$endDate'
GROUP BY search_engine
Additionally, your '... when =< ' is incorrect (Atleast in common programming languages) - You need to put the less than sign first <= instead of =<.