Showing Error while insertion of data in database, Drupal 7 I am new to drupal, and i am trying to insert data in database from form using Database API.
But its showing an error. That error is given below:

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'x1' doesn't have a default value: INSERT INTO {members} (first_name, last_name, email, username, password, country) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] =&gt; Ravneet [:db_insert_placeholder_1] =&gt; Singh [:db_insert_placeholder_2] =&gt; rvtsingh@gmail.com [:db_insert_placeholder_3] =&gt; rvtsingh [:db_insert_placeholder_4] =&gt; 123456 [:db_insert_placeholder_5] =&gt; India ) in form_test_form_submit() (line 63 of C:\wamp\www\Biding\sites\all\modules\own\form_test\form_test.module).


The code I used in module file to create code and insert in database is :

&lt;?php
function form_test_menu() {
  $items['formtest'] = array(
    'title' =&gt; 'Sign up',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('form_test_form'),
    'access callback' =&gt; TRUE,
    );
  return $items;
}

function form_test_form($form, &amp;$form_submit) {
  $form['firstname'] = array(
    '#title' =&gt; t('Firstname'),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );
  $form['lastname'] = array(
    '#title' =&gt; t('Lastname'),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );
  $form['email'] = array(
    '#title' =&gt; t('Email'),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );
  $form['username'] = array(
    '#title' =&gt; t('Username'),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );
  $form['password'] = array(
    '#title' =&gt; t('Password'),
    '#type' =&gt; 'password',
    '#required' =&gt; TRUE,
  );
  $form['country'] = array(
    '#title' =&gt; t('Country'),
    '#type' =&gt; 'select',
    '#options' =&gt; array('India' =&gt; 'India', 'Pakistan' =&gt; 'Pakistan', 'USA' =&gt; 'USA', 'UK' =&gt; 'UK', 'China' =&gt; 'China'),
    '#required' =&gt; TRUE,
  );
  $form['submit'] = array(
    '#value' =&gt; 'Submit',
    '#type' =&gt; 'submit',
    );
  return $form;
}

function form_test_form_submit($form, $form_submit) {

  global $user;
    $user = db_insert('members')
    -&gt;fields(array(
        'first_name' =&gt; $form_submit['values']['firstname'],
        'last_name' =&gt; $form_submit['values']['lastname'],
        'email' =&gt; $form_submit['values']['email'],
        'username' =&gt; $form_submit['values']['username'],
        'password' =&gt; $form_submit['values']['password'],
        'country' =&gt; $form_submit['values']['country'],
    ))
    -&gt;execute();

    drupal_set_message("You have registered successfully.");

}


Please help me to resolve this error. Thanks in advance.
Looks like the issue is related to your mysql table member structure. The member table field x1 doesn't have a default value that means you need to serve a value on every insert,  you can solve this in three ways,


Pass the value in the field array Ex: 'x1' =&gt; "&lt;value here&gt;",
Add a default value / NULL (based on your requirement) through altering your table 



  (ALTER TABLE member CHANGE x1 x1 NOT NULL DEFAULT '') OR (ALTER TABLE member CHANGE x1 x1 NULL)


3.Check your table mode, if the table mode is STRICT change it to SET GLOBAL sql_mode=''; REFERENCE : SQL Mode