Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Invalid default value on mysql.

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

baris22

Established Member
Impact
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
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
it works 100% here

you could always try changing article_id int(11) NOT NULL default '', to:-

article_id int(11) default '',
 
0
Close
Although it should generally work it might depend on the MySQL version. But as this is an integer field I'd rather suggest the following definition.

article_id int(11) NOT NULL default 0,
 
0
Close
neroux if he does that there is a potential problem. If for example he has an article with an id of 0 when selecting by article_id he will have 2 to choose from.
 
0
Close
Given that the articles are based on autoincrement values an article should never get a 0. But even if one does, it wouldnt matter.

Anyhow, although '' should work for an integer value it is syntactically wrong. Also allowing NULL could lead to unassociated comments.
 
0
Close
neroux said:
Given that the articles are based on autoincrement values an article should never get a 0. But even if one does, it wouldnt matter.

Anyhow, although '' should work for an integer value it is syntactically wrong. Also allowing NULL could lead to unassociated comments.

Well that is something he would have to weigh up. What would be worse having data within the database that was not associated with a proper record or 1 that could potentially return incorrect data.
 
0
Close
peter@flexiwebhost said:
Well that is something he would have to weigh up. What would be worse having data within the database that was not associated with a proper record or 1 that could potentially return incorrect data.
A NULL value is only recommended when the field does not necessarily need a value, for an association it should never be NULL.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back