Jump to content

[SOLVED] SQL N00b with syntax issues


FlashbackJon

Recommended Posts

I'm working from a few tutorials at once and trying to customize to my purposes while I do so.  That's probably not the best solution, but I was pretty confident until I reached the first step and got hit in the groin.

 

I'm trying to run the following SQL command on my existing MySQL 4.0.25 database via the php_my_admin 2.6.4-pl4 interface:

 

CREATE TABLE fc_user (
userID int(10) UNSIGNED NOT NULL auto_increment PRIMARY,
userName varchar(15) NOT NULL UNIQUE,
encryptPass varchar(32) NOT NULL,
userPass varchar(15) NOT NULL,
userDisplayName varchar(250) NOT NULL,
userEmail varchar(100) NOT NULL,
userSignupDate datetime NOT NULL default="now()",
userLocation varchar(100),
userTimeZoneOffset varchar(4) default="-6",
userWebsite varchar(250) default="http://",
userAIM varchar(100),
userMSN varchar(100),
userYahoo varchar(100),
userICQ varchar(100),
userSkype varchar(100),

PRIMARY KEY (userID)
);

 

It keeps firing back with the following error:

MySQL said: Documentation

#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 '

userName varchar(15) NOT NULL UNIQUE,

encryptPass varchar(32

I've tried removing the "unique", removing the field declaration itself, fiddling in every way I can think of but I seriously cannot figure out what's wrong with it.  It just selects the text starting at that line regardless.

 

Thoughts and patience for a n00b?

Link to comment
https://forums.phpfreaks.com/topic/47346-solved-sql-n00b-with-syntax-issues/
Share on other sites

have you tried removing PRIMARY or adding the word KEY

 

and consider changing

userSignupDate datetime NOT NULL default="now()",

to

userSignupDate timestamp NOT NULL default timestamp,

 

remove all the = signs and define the primary key either in the column definition or the statement footer

 

The addition of "KEY" fixed the first problem.  Removing the equal signs also killed some errors.

 

Then the datetime field started causing issues, I looked into it, trying about a dozen different options.  Turns out default can't be set as a function (now()) and my host is using an older version of MySQL, so timestamps operate funny.

 

Anyhow, I got it to work, if not ideally yet.  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.