How do I get values of checkboxes?
Assuming that your $resultarray variable in the form actually has some data in it, this code will get you a list of the ids that have been selected:

function friendmodule_form_submit($form, &amp;$form_state) {   
  $friend_ids = array_filter($form_state['values']['friends']);
}


When a checkboxes element is submitted all of the original option keys will be in the $form_state['values']'friends'] array, but only the ones that have been selected will have a positive value; the rest will have a value of zero, so you need to use array_filter() to extract only the IDs for options that have been selected.

Also, at the moment you have a syntax error in your submit function (an extra closing )), maybe that's what is causing the error.