-2

Here we go again. MySQL throws this 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 'tinytext not null, FirstName varchar(50) not null, LastName varchar(50) nu' at line 5

What can be the possible syntax problem for this?

Here's the code:

    CREATE TABLE posts (
        ID int unsigned not null auto_increment,
        Type enum('article', 'link') not null,
        Title text null,
        Link text null,
        BodyOrig longtext null,
        BodyProc longtext not null,
        URL tinytext not null,
        ShortURL tinytext not null,
        Status enum('drafted', 'published') not null,
        DateEdited timestamp null,
        DatePublished timestamp null,
        Topic enum('') null,

        primary key (ID, URL(255), ShortURL(10))
    );
    CREATE TABLE pages (
        ID int unsigned not null auto_increment,
        Name varchar(25) not null,
        Title text not null,
        BodyOrig longtext null,
        BodyProc longtext not null,
        URL tinytext not null,
        Hero text null,
        Status enum('drafted', 'published') not null,

        primary key (ID, Name, URL(255))
    );
    CREATE TABLE users (
        ID int unsigned not null auto_increment,
        Username varchar(25) not null,
        Password text not null,
        Key tinytext not null,
        FirstName varchar(50) not null,
        LastName varchar(50) null,
        DisplayName tinytext not null,
        Email tinytext not null,

        primary key (ID, Username, Key(255));
    );
    CREATE TABLE settings (
        Version varchar(10) not null,
        SiteName tinytext not null,
        Description tinytext not null,
        ColorScheme char(6) not null
    );

Either my eyes are just not in their tip-top shape, or there is something (specific formatting?) I am missing. Thank you very much for your help!

Jocelyn
  • 11,209
  • 10
  • 43
  • 60
Raffy Alcoriza
  • 137
  • 1
  • 3
  • 13
  • possible duplicate of [Syntax error due to using a reserved word as a table or column name in MySQL](http://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved-word-as-a-table-or-column-name-in-mysql) – Ian Ringrose May 06 '14 at 09:55

1 Answers1

4

You're trying to create a column named "Key" which is a reserved keyword.

Carth
  • 2,303
  • 1
  • 17
  • 26
  • Thanks. That worked a bit better. Now I got this. `#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 11 ` – Raffy Alcoriza Sep 22 '12 at 02:57
  • 1
    Try escaping all entities - `tableName`, `field` name. – KV Prajapati Sep 22 '12 at 03:01
  • That means? (Sorry, total noob here.) – Raffy Alcoriza Sep 22 '12 at 03:09
  • You have a typo at the end of your user table definition. You need to remove the semi-colon after the key line here. primary key (ID, Username, Key(255)); . Keeping in mind that the "Key" value here should have been changed as well. If you found this helpful please be sure to accept it as the answer :) – Carth Sep 22 '12 at 03:17
  • @Carth thanks but that has been fixed already. My problem is now a new 1064 quoted above. – Raffy Alcoriza Sep 22 '12 at 03:23