Update Mysql table row I'm new to Drupal and its SQL API, and I am trying to update a row in a table I created.

// Admin form
function admin_Form($form, &amp;$form_state) {
  $dbval = getVals();
  $form = array();

  $form['firstname'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'Fornavn',
    '#id' =&gt; 'fornavn',
    '#value' =&gt;  $dbval['firstname'],
  );

  $form['lastname'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'Efternavn',
    '#id' =&gt; 'efternavn',
    '#value' =&gt;  $dbval['lastname'],
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Save'
  );

  return $form;
}

function admin_Form_submit($form, &amp;$form_state) {
  $update_zoho = db_update('zoho')
    -&gt;fields(array(
      'firstname' =&gt; $form_state['values']['firstname'],
      'lastname' =&gt; $form_state['values']['lastname'],
    ))
    -&gt;condition('lastname', 'lastname', '=')
    -&gt;execute();
}


Everything gets executed and the message gets displayed, but the row is not updated.

Can anyone point a newbie in the right direction?
These are the table structure and the values is contains.


    title, firstname, lastname,  city, ... lots of colums
    ------------------------------------------------------
          - Bolli    - lastname - KBH  .... 
          -          -          -     
          -          -          -   
          -          -          -
You need a condition() so that it knows which record to update.  When you don't give a condition, it just doesn't update anything.  More Info on db_update()

The following says, "Update firstname to formvalue, lastname to formvalue WHERE the last name as stored in database is 'Bolli'".  To avoid conflicts, your table should have a field that contains a unique value for each entry, such as an auto-increment primary key.  That way, you can say "UPDATE ... WHERE id = unique_id".

$update_zoho = db_update('zoho')
  -&gt;fields(array(
     //'title' =&gt; $form_state['values']['title'],
     'firstname' =&gt; $form_state['values']['firstname'],
     'lastname' =&gt; $form_state['values']['lastname'],
  ))
  -&gt;condition('lastname', 'Bolli', '=')
  -&gt;execute();