Click to See Complete Forum and Search --> : Trouble with MYSQL Syntax


Megatron
02-13-2006, 01:00 PM
Hi guys, i'm following a tutorial on php/mysql and i'm attempting to input this sql code into a db in phpmyadmin
CREATE TABLE `databasename`.`cmsarticles` (
`ID` int(6) unsigned NOT NULL auto_increment COMMENT 'The unique ID of the article',
`title` varchar(200) NULL COMMENT 'The article title',
`tagline` varchar(255) NULL COMMENT 'Short summary of the article',
`section` int(4) NULL DEFAULT 0 COMMENT 'The section of the article',
`thearticle` text NULL COMMENT 'The article itself',
PRIMARY KEY (`ID`)
);

The writer of the tutorial said a simple copy and paste just see the MYSQL db setup, but i have attempted to alter the code and remove some of the " ' " from the code and i keep getting erorr's. The error i get when i attemp to run that code is You have an error in your SQL syntax near 'COMMENT 'The unique ID of the article', `title` varchar(200) NULL COMMENT 'The a

Any help is much appriciated.
MegaTron

NogDog
02-13-2006, 03:28 PM
Not sure if this is the problem, but how about trying:

...
`ID` int(6) unsigned NOT NULL auto_increment PRIMARY KEY COMMENT 'The unique ID of the article',
...

Megatron
02-13-2006, 04:21 PM
I have modified the code to this after according to your post
CREATE TABLE cmsarticles(
ID int( 6 ) unsigned NOT NULL auto_increment PRIMARY KEY ,
title varchar( 200 ) NULL ,
tagline varchar( 255 ) NULL ,
section int( 4 ) NULL DEFAULT 0,
thearticle text NULL ,
)

i'm still getting "You have an error in your SQL syntax near ')' at line 1" as an error message thou

NogDog
02-13-2006, 04:43 PM
The last comma (just before the closing parenthese) needs to be deleted.