View Full Version : CREATE Query Problem
SDP2006
01-05-2004, 03:30 AM
CREATE TABLE Auth(
id MEDIUMINT NOT NULL AUTO_INCREMENT,
User varchar(255) NOT NULL DEFAULT '0',
Pass varchar(255) NOT NULL DEFAULT '0',
Level int(20) NOT NULL DEFAULT '0',
PRIMARY KEY(id);
)Type=MyISAM;
Returns the error #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 '' at line 6 But I cannot figure out what is causing this error. All help is appreciated. Thanks
SDP2006
01-05-2004, 09:15 PM
Anyone :)
Nightfire
01-05-2004, 10:46 PM
Tried taking this bit off?
Type=MyISAM;
Or it could just be the semi-colon at the end of that line, try just taking that off
SDP2006
01-05-2004, 11:38 PM
It still returns the same error. I'm stumped :(
Nightfire
01-05-2004, 11:42 PM
CREATE TABLE Auth(
id MEDIUMINT NOT NULL AUTO_INCREMENT,
User varchar(255) NOT NULL DEFAULT '0',
Pass varchar(255) NOT NULL DEFAULT '0',
Level int(20) NOT NULL DEFAULT '0',
PRIMARY KEY(id)
)
That worked for me in phpmyadmin
SDP2006
01-06-2004, 12:03 AM
Well, it worked for me too. Oh well. Thanks nightfire :)
whackaxe
01-06-2004, 09:17 AM
in php you don't include semi colons at the end of your queries (unlike the mysql client for example) you also put it in the wrong place i think, before the ")".
That will indeed have been the problem.
But why do you have a default set for the user and pass? It can only create aditional risks (imagen that somehow, a record gets inserted without pass or user, then people could log in with username and pwd = 0) and there is no reason to include it. You also best limit the number of characters. Even if you hash them, i think that 50 characters will do. No?
And will you have that many levels? If you would use TINYINT UNSIGNED , then you could have up to 255 levels, which probably should be more then enough.
int(20) means that you can have level-values from -2147483648 to 2147483647 with a maximum diplay-size of 20 (which is impossible given the bounds). I suppose you wanted a column to store the level with a maximum of 20 --> use the TINYINT UNSIGNED then.
It's important to always choose the smallest possible column-type and length (if relevant) because the mysql server will reserve memoryspace (when processing records) according to the tabledefinition. So with your specifications, you will reserve at least 5 times more (of the most expensive) memoryspace then you actually need.
You better start getting familiar with picking the right columntypes and lengths from the start on, because when you later on need to administer a highly queryed db, you'll notice the differences.
SDP2006
01-06-2004, 11:53 PM
To tell you the truth guys, I don't really know a whole heck of a lot about MySQL. I know how to create, insert, and select and that is about it.
What you know is less important then what you want to learn...
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.