How to put a condition on a query
Clive's comment is right.  You should understand the reasons why, however,  I will give you the short answer ;)

Use db_select()

$query = db_select('challenges', 'c');
$query-&gt;fields('c');
$query-&gt;condition('c.cid', $id, '='); 
$result = $query-&gt;execute();