NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Invalid default value on mysql.

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-01-2007, 11:40 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



Invalid default value on mysql.


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 '',
????: NamePros.com http://www.namepros.com/programming/390932-invalid-default-value-on-mysql.html
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 is offline  
Old 11-01-2007, 01:23 PM   #2 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
it works 100% here

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

article_id int(11) default '',
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 11-01-2007, 01:31 PM   #3 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



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,
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Old 11-01-2007, 01:54 PM   #4 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 11-01-2007, 02:01 PM   #5 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



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.
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Old 11-01-2007, 02:06 PM   #6 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by neroux
Given that the articles are based on autoincrement values an article should never get a 0. But even if one does, it wouldnt matter.
????: NamePros.com http://www.namepros.com/showthread.php?t=390932

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.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 11-01-2007, 02:22 PM   #7 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



Originally Posted by peter@flexiwebhost
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.
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:50 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger