#1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    16
    I am trying to create a table for some articles. And this SQL isn't working. Please can someone explain why!

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    CREATE TABLE articles (
    name varchar(30),
    email varchar(30),
    club varchar(40),
    problem text,
    solution text,
    id varchar(20),
    section varchar(20),
    date varchar(20),
    time varchar(5),
    channel varchar(1),
    coaching text,
    explain text,
    subject varchar(40),
    PRIMARY KEY(id)
    );

    [/code]

    Thanks,
    --------------------------------------------
    Alex
    (http://www.alex-greg.co.uk)
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    date is a reserved word and cannot be used for a field name.
  4. #3
  5. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    16
    If date is a reserved field, then how comes this work?

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    CREATE TABLE noticeboard (
    name varchar(30),
    email varchar(30),
    club varchar(40),
    problem text,
    solution text,
    id int(11) NOT NULL,
    section varchar(20),
    date varchar(20),
    time varchar(5),
    PRIMARY KEY (id)
    );


    [/code]

    I am making some upgrades on this script and so I have had to modify the database. When I try to add this table via phpMyAdmin, I get this:

    MySQL said: You have an error in your SQL syntax near 'explain text, subject varchar(40), PRIMARY KEY(id) )' at line 13
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    My mistake. Date is not reserved, explain is.
  8. #5
  9. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    16
    OK thanks....are there any other reserved fields like this??
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    They are listed in the manual. Too many to list here.

Similar Threads

  1. Phantom SQL Syntax Error
    By cparker in forum Perl Programming
    Replies: 3
    Last Post: February 12th, 2004, 12:38 PM
  2. SQL Statement Help
    By CrazyeD in forum ASP Programming
    Replies: 1
    Last Post: January 26th, 2004, 03:09 PM
  3. Is my SQL wrong? I checked forever, can't find a thing.
    By Pixelfusion in forum PHP Development
    Replies: 4
    Last Post: December 27th, 2003, 10:59 PM
  4. Replies: 2
    Last Post: December 1st, 2003, 08:49 AM
  5. Replies: 2
    Last Post: November 29th, 2003, 09:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo