dq_609586475 2013-09-14 19:10
浏览 184

数据库错误“字段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;
  • 写回答

3条回答 默认 最新

  • du1913 2013-09-14 19:24
    关注

    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
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!