Reputation: 13
I used the phpMyAdmin form to create a table, i.e. I filled in the fields and it generated the code. The code generated doesn't work, but I can't find the error. Any help would be appreciated.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( 1 ) NOT NULL DEFAULT '0',
userEmail VARCHAR( 255 ) NOT NULL ,PRIMARY KEY (' at line 14
Here's the code:
CREATE TABLE members (
userID INT( 9 ) NOT NULL AUTO_INCREMENT ,
userName VARCHAR( 15 ) NOT NULL ,
userPwd VARCHAR( 16 ) NOT NULL ,
userTitle VARCHAR( 4 ) NOT NULL ,
fName VARCHAR( 30 ) NOT NULL ,
lName VARCHAR( 30 ) NOT NULL ,
address VARCHAR( 255 ) NULL ,
dateOfBirth VARCHAR( 10 ) NULL ,
userJob VARCHAR( 15 ) NULL ,
regDate VARCHAR( 20 ) NOT NULL ,
accType CHAR( 1 ) NOT NULL DEFAULT 'F',
regCode VARCHAR( 255 ) NOT NULL ,
isActivated BOOL( 1 ) NOT NULL DEFAULT '0',
userEmail VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( userID ) ,
UNIQUE (userName ,userEmail)
) ENGINE = MYISAM
mysql ver 5.1 php ver 5.2.*
Upvotes: 1
Views: 1154
Reputation: 1828
Change
isActivated BOOL( 1 ) NOT NULL DEFAULT '0',
to
isActivated BOOL NOT NULL DEFAULT '0',
you can read about it more : here
M indicates the maximum display width for integer types
Bool does not have this so you can't specify width. it's always 1
Upvotes: 2
Reputation: 8744
You cannot use BOOL(1)
Try the following (i just replaced BOOL(1) with BOOL)
BOOL and BOOLEAN are synonyms for TINYINT(1).
CREATE TABLE members (
userID INT( 9 ) NOT NULL AUTO_INCREMENT ,
userName VARCHAR( 15 ) NOT NULL ,
userPwd VARCHAR( 16 ) NOT NULL ,
userTitle VARCHAR( 4 ) NOT NULL ,
fName VARCHAR( 30 ) NOT NULL ,
lName VARCHAR( 30 ) NOT NULL ,
address VARCHAR( 255 ) NULL ,
dateOfBirth VARCHAR( 10 ) NULL ,
userJob VARCHAR( 15 ) NULL ,
regDate VARCHAR( 20 ) NOT NULL ,
accType CHAR( 1 ) NOT NULL DEFAULT 'F',
regCode VARCHAR( 255 ) NOT NULL ,
isActivated BOOL NOT NULL DEFAULT '0',
userEmail VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( userID ) ,
UNIQUE (userName ,userEmail)
) ENGINE = MYISAM
Upvotes: 3