Valhalla Legends Archive

Programming => Web Development => Topic started by: Alendar on February 10, 2008, 04:12 PM

Title: MySQL Error 1064 with this code
Post by: Alendar on February 10, 2008, 04:12 PM
When trying to execute this code:

CREATE TABLE `pastebin` (
`pid` int(11) NOT NULL auto_increment,
`poster` varchar(16) default NULL,
`posted` datetime default NULL,
`code` text,
`parent_pid` int(11) default '0',
`format` varchar(16) default NULL,
`codefmt` mediumtext,
`codecss` text,
`domain` varchar(255) default '',
`expires` DATETIME,
`expiry_flag` ENUM('d','m', 'f') NOT NULL DEFAULT 'm',

PRIMARY KEY (`pid`),
KEY `domain` (`domain`),
KEY `parent_pid`,
KEY `expires`
);


I get the following error:

Quote#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 '
KEY `expires`
)' at line 16
I am trying to install PasteBin an open source code. Yet I get this error when trying to install this part. Thanks for the help!


Alendar
Title: Re: MySQL Error 1064 with this code
Post by: iago on February 10, 2008, 05:03 PM
MySQL requires the KEYs to have a list of columns (which makes sense), in addition to an optional name. On that query, the last two KEYs only have names, not columns.

This should work:

CREATE TABLE `pastebin` (
`pid` int(11) NOT NULL auto_increment,
`poster` varchar(16) default NULL,
`posted` datetime default NULL,
`code` text,
`parent_pid` int(11) default '0',
`format` varchar(16) default NULL,
`codefmt` mediumtext,
`codecss` text,
`domain` varchar(255) default '',
`expires` DATETIME,
`expiry_flag` ENUM('d','m', 'f') NOT NULL DEFAULT 'm',

PRIMARY KEY (`pid`),
KEY `domain` (`domain`),
KEY (`parent_pid`),
KEY (`expires`)
);
Title: Re: MySQL Error 1064 with this code
Post by: Alendar on February 10, 2008, 09:08 PM
That worked. Thank you!