Error in db_query statement - d7 The below query is giving error:

PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in webform_options_submit()

What am I missing? Any suggestions/ideas will be helpful.

And, How should I use the LIKE command in this query?

  $args = array(':entities' =&gt; $_REQUEST['entities'], ':countries'=&gt;$_REQUEST['countries']);
  $query = db_query("SELECT field_entity_value,field_country_value, filename
                   FROM field_data_field_entity,field_data_field_country , field_revision_field_file_upload, file_managed
                   WHERE ( field_data_field_entity.field_entity_value LIKE :entities
                   AND field_data_field_country.field_country_value= :countries )
                   AND field_data_field_entity.entity_id = field_revision_field_file_upload.entity_id
                   AND field_data_field_country.entity_id= field_data_field_entity.entity_id
                   AND field_revision_field_file_upload.field_file_upload_fid=file_managed.fid", $args);                            
  $results = $query-&gt;execute();
Try it without the $query->execute(); as according to the docs for db_query the function already executes the query and returns a result.

Try this:

$args = array(':entities' =&gt; $_REQUEST['entities'], ':countries'=&gt;$_REQUEST['countries']);
$result = db_query("SELECT field_entity_value,field_country_value, filename
                   FROM field_data_field_entity,field_data_field_country , field_revision_field_file_upload, file_managed
                   WHERE ( field_data_field_entity.field_entity_value LIKE :entities
                   AND field_data_field_country.field_country_value= :countries )
                   AND field_data_field_entity.entity_id = field_revision_field_file_upload.entity_id
                   AND field_data_field_country.entity_id= field_data_field_entity.entity_id
                   AND field_revision_field_file_upload.field_file_upload_fid=file_managed.fid", $args);


I would say the error is from trying to execute a result.