数据库错误“字段X没有默认值”是什么意思?

Below is my form and table that I have created for my signup newsletter. When I try to enter a new person into the form I get this message. What do I have to do to fix this problem?

**Field 'ip_address' doesn't have a default value INSERT INTO member SET join_date = NOW() , first_name = 'John', last_name = 'D', email = 'jd@aol.com'

Field 'unsubscribe_date' doesn't have a default value INSERT INTO member SET join_date = NOW() , first_name = 'John', last_name = 'D', email = 'jd@aol.com'

Field 'unsubscribe_send_id' doesn't have a default value INSERT INTO member SET join_date = NOW() , first_name = 'John', last_name = 'D', email = 'jd@aol.com'**

Here's my form:

    <table cellpadding="3" width="100%">
    <tbody>
        <tr>
            <td>Email <span class="required">*</span></td>
            <td><input type="text" class="text_input" name="email" value=""></td>
        </tr>
        <tr>
            <td>First Name <span class="required">*</span></td>
            <td><input type="text" class="text_input" name="first_name" value=""></td>
        </tr>
        <tr>
            <td>Last Name</td>
            <td><input type="text" class="text_input" name="last_name" value=""></td>
        </tr>
                    <tr>
            <td>
            Subscribed Communication
            </td>
            <td>
                <table>
                                                <tr>
                            <td><input type="checkbox" name="group_id[]" value="2" checked></td>
                            <td>RaceO'Clock Members</td>
                        </tr>
                                                                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" name="submit" value="Subscribe!"> <br/>
                <em>* required fields</em>
            </td>
        </tr>
    </tbody>
    </table>


    </form>

This is my table:

CREATE TABLE IF NOT EXISTS `member` (
  `member_id` int(11) NOT NULL auto_increment,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `join_date` date NOT NULL,
  `ip_address` varchar(15) NOT NULL,
  `unsubscribe_date` date NOT NULL,
  `unsubscribe_send_id` int(11) NOT NULL,
  PRIMARY KEY  (`member_id`)
)  DEFAULT CHARSET=utf8;

Fields that are not null without a default value are required in an insert statement.

You have three choices :

  1. Define a default value
  2. Change the column definition to allow null
  3. Add that column to the insert statement

You are creating table with NOT NULL in all columns which means column cant be NULL when you insert values.

If you want make NOT NULL then you should make a DEFAULT value of this column.

Use this:

     CREATE TABLE IF NOT EXISTS `member` (
     `member_id` int(11) NOT NULL auto_increment,
     `first_name` varchar(255) ,
     `last_name` varchar(255) ,
     `email` varchar(255) ,
      `join_date` date ,
      `ip_address` varchar(15),
      `unsubscribe_date` date ,
      `unsubscribe_send_id` int(11) ,
     PRIMARY KEY  (`member_id`)
    )  DEFAULT CHARSET=utf8;

Or add that column to insert statement and insert a empty string.

Like that:

INSERT INTO member SET join_date = NOW() , 
                      first_name = 'John', 
                       last_name = 'D',
                           email = 'jd@aol.com' ,
                      ip_address = '' ,
                unsubscribe_date = '',
             unsubscribe_send_id = ''

It is caused by the STRICT_TRANS_TABLES that is defined in the %PROGRAMDATA%\MySQL\MySQL Server 5.6\my.ini file. After removing that setting, restart MySQL to fix the problem.