Recoverable fatal error after form submission in drupal7 Iam new to drupal.I have created a custom module named firstmodule .I have created a form using the tutorials section of drupal 7
when is submit i want to store this details in the registration which is present in db.

firstmodule.module

function firstmodule_form1_submit($form, &amp;$form_state)

{

$firstname = $form_state['values']['name'];
    $username = $form_state['values']['username'];
    $password = $form_state['values']['password'];
    $year_of_birth = $form_state['values']['year_of_birth'];
    $email = $form_state['values']['email'];
    $file = $form_state['values']['file'];


I am using the insert query in the following way:

        db_insert('registration')-&gt;fields(array(
          'firstname' =&gt; $firstname,
          'username' =&gt; $username,
          'password' =&gt; $password,
          'yearofbirth' =&gt;$year_of_birth,
          'email' =&gt; $email,
          'file' =&gt; $file,))
          -&gt;execute();
}


it is showing me the error 


  Recoverable fatal error: Object of class stdClass could not be
  converted to string in DatabaseStatementBase->execute() (line 2168 of
  /var/www/drupal-7.22/includes/database/database.inc).


please help with it
Here is an example of a file upload with some validation, hope it helps

function file_upload_form_validate($form, &amp;$form_state) {

  $file = file_save_upload('file', array(
    'file_validate_extensions' =&gt; array('txt csv'), 
    'file_validate_size' =&gt; array(10000000),
  ));
  // If the file passed validation:
  if ($file) {
    // Move the file, into the Drupal file system
    if ($file = file_move($file, 'public://')) {
      // Save the file for use in the submit handler.
      $form_state['storage']['file'] = $file;
    }
    else {
      form_set_error('file', 'there was an error uploading the file');
    }
  }
  else {
    form_set_error('file', 'No file uploaded');
  }
}

function file_upload_form_submit($form, &amp;$form_state) {
  $file = $form_state['storage']['file'];
  // We are done with the file, remove it from storage.
  unset($form_state['storage']['file']);
  // Make the storage of the file permanent
  $file-&gt;status = FILE_STATUS_PERMANENT;
  // Save file status.
  file_save($file);
  // here you can save your data
  $firstname = $form_state['values']['name'];
  $username = $form_state['values']['username'];
  $password = $form_state['values']['password'];
  $year_of_birth = $form_state['values']['year_of_birth'];
  $email = $form_state['values']['email'];

  db_insert('registration')-&gt;fields(array(
    'firstname' =&gt; $firstname,
    'username' =&gt; $username,
    'password' =&gt; $password,
    'yearofbirth' =&gt;$year_of_birth,
    'email' =&gt; $email,
    'file' =&gt; $file-&gt;uri,))
  -&gt;execute();

}