Invalid default value for ..

Discussion in 'Databases' started by baris22, Nov 1, 2007.

  1. #1
    Hello,

    I am triying to install this database but i get an error. Error message is #1067 - Invalid default value for 'article_id'

    Here is my database


    create table articles (
    id int(11) NOT NULL auto_increment,
    name varchar(30) NOT NULL default '',
    title varchar(40) NOT NULL default'',
    content text NOT NULL,
    date datetime NOT NULL default'0000-00-00 00:00:00',
    ip varchar(20) NOT NULL default'',
    primary key (id)
    ) TYPE=MyISAM auto_increment=1 ;

    create table comments (
    id int(11) NOT NULL auto_increment,
    article_id int(11) NOT NULL default '',
    name varchar(30) NOT NULL default '',
    website varchar(50) NOT NULL default '',
    email varchar(50) NOT NULL default '',
    comment text NOT NULL,
    date datetime NOT NULL default'0000-00-00 00:00:00',
    ip varchar(20) NOT NULL default '',
    primary key (id)
    ) TYPE=MyISAM auto_increment=1 ;


    Thanks for your help
     
    baris22, Nov 1, 2007 IP
  2. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #2
    it's an integer, you cannot default value it as a string value ('' is a string value)

    you will need to default a number
     
    Lordy, Nov 1, 2007 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for your reply. How can i solve the problem?

    Thanks
     
    baris22, Nov 1, 2007 IP
  4. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ...

    change the default to a number.....
     
    Lordy, Nov 1, 2007 IP
  5. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    article_id int(11) NOT NULL default 0,

    OR

    article_id int(11) NOT NULL,

    with the latter, if you insert something without setting the value for article_id, the db may throw an error (depending on which db you use).
     
    phper, Nov 1, 2007 IP