homepage Welcome to WebmasterWorld Guest from 54.237.99.131
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Can Anyone Tell Me What I am doing wrong?
I just want to start out learning something simple like a guest log.
Conscientious Reject

5+ Year Member



 
Msg#: 207 posted 3:58 am on Dec 22, 2005 (gmt 0)

Can anyone help? PLEEEEZZZZZE!

#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 'UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT, `lastName` VARCHAR(30) DEFAULT '0'' at line 1

CREATE TABLE `guestLog` (

`firstName` VARCHAR( 30 ) UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT ,
`lastName` VARCHAR( 30 ) DEFAULT '0' NOT NULL ,
`email` VARCHAR( 60 ) UNSIGNED DEFAULT '0' NOT NULL ,
`phone` VARCHAR( 10 ) UNSIGNED DEFAULT '0' NOT NULL ,
`userID` VARCHAR( 20 ) DEFAULT '0' NOT NULL ,
`passWord` VARCHAR( 10 ) DEFAULT '0' NOT NULL ,
`excerpt` VARCHAR( 1000 ) ,
`city` VARCHAR( 60 ) ,
`state` VARCHAR( 2 ) ,
`webSite` VARCHAR( 60 ) ,
`career` VARCHAR( 60 ) ,
PRIMARY KEY ( `userID` )
) TYPE = MYISAM

 

Dreamquick

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 207 posted 2:34 pm on Dec 22, 2005 (gmt 0)

By the look of it you've got some data-types and keywords mixed up, try this instead...

CREATE TABLE `guestLog` (
`firstName` VARCHAR( 30 ),
`lastName` VARCHAR( 30 ),
`email` VARCHAR( 60 ),
`phone` VARCHAR( 10 ),
`userID` INTEGER NOT NULL AUTO_INCREMENT,
`passWord` VARCHAR( 10 ),
`excerpt` TEXT,
`city` VARCHAR( 60 ),
`state` VARCHAR( 2 ),
`webSite` VARCHAR( 60 ),
`career` VARCHAR( 60 ),
PRIMARY KEY ( `userID` )
) TYPE = MYISAM

It's a simplified version of what you started out with, feel free to add in NOT NULL and DEFAULT as appropriate for your fields.

I've removed the UNSIGNED's from the VARCHAR (text) fields because UNSIGNED is a keyword for numeric fields, I've removed the DEFAULT('0') because on the whole they didn't seem to be using appropriate or useful defaults.

Lastly I've moved your AUTO_INCREMENT from firstName to userID, then changed userID to an INTEGER (numeric) before making it the primary key. This should give you an automatically-generated unique numeric key for each record entered, which is what a userID / primary key should generally be.

Also changed excerpt to TEXT rather than VARCHAR(1000) because VARCHAR is limited to 255 characters in the existing mySQL engines, the db would have worked around it but figured might as well keep the example tidy.

- Tony

Conscientious Reject

5+ Year Member



 
Msg#: 207 posted 5:16 pm on Dec 22, 2005 (gmt 0)

thanks Tony,

I will give it shot when I get home tonight, and let you know how it came out. Also, I will soon be posting a discussion on how to define a forum data type. I haven't even got that far yet (and it may be a week or two), but I know I am going to have problems. Thanks for all your help.

Mitchell

Conscientious Reject

5+ Year Member



 
Msg#: 207 posted 5:37 am on Dec 23, 2005 (gmt 0)

You rock Tony...

Thanks for your help.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved