#1067 - Invalid default value for 'membership'

user1890162 picture user1890162 · Dec 9, 2012 · Viewed 18.1k times · Source

I am using a SQL file included in my program and once I fixed an issue that I was able to find the answer to in here (THANK YOU).. I ran it again and got the following error:

SQL query:

# Create table structure for 'member' table
CREATE TABLE member(

memberID INT( 11 ) NOT NULL AUTO_INCREMENT ,  
title VARCHAR( 80 ) NOT NULL DEFAULT  '',  
firstname VARCHAR( 80 ) NOT NULL DEFAULT  '',  
lastname VARCHAR( 80 ) NOT NULL DEFAULT  '',  
email VARCHAR( 80 ) NOT NULL DEFAULT  '',  
address VARCHAR( 80 ) NOT NULL DEFAULT  '',  
suburb VARCHAR( 80 ) NOT NULL DEFAULT  '',  
state VARCHAR( 80 ) NOT NULL DEFAULT  '',  
country VARCHAR( 80 ) NOT NULL DEFAULT  '',  
postcode VARCHAR( 11 ) NOT NULL DEFAULT  '',  
mobile VARCHAR( 80 ) NOT NULL DEFAULT  '',  
phone VARCHAR( 80 ) NOT NULL DEFAULT  '',  
fax VARCHAR( 80 ) NOT NULL DEFAULT  '',  
membership INT( 2 ) NOT NULL DEFAULT  '',  
payment INT( 2 ) NOT NULL DEFAULT  '',  
startdate BIGINT( 14 ) NOT NULL DEFAULT 0,  
enddate BIGINT( 14 ) NOT NULL DEFAULT 0,  
userID INT( 11 ) NOT NULL ,  
PRIMARY KEY ( memberID ) ,  
UNIQUE (  
memberID  
)  
) ENGINE = MYISAM ;

MySQL said:

#1067 - Invalid default value for 'membership' 

What do I need to change to make this work ? this is an older script, but I am not knowledgeable enough to know what needs to be changed for MySQL 5.5 version.

Thank you so much for your help!

And I'm sure there will be other errors popping up after I fix this one..

Answer

Marvo picture Marvo · Dec 9, 2012

The membership column is an int, but you're giving it a default string value of ''. So change

 membership INT( 2 ) NOT NULL DEFAULT '',

to

 membership INT( 2 ) NOT NULL DEFAULT 0,

(0 or whatever default value you want for that field.)