SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    What is wrong with this query?!!?

    I was using phpMyAdmin and it gave me an error on a query it created!! And it keeps giving me the error...

    Any help would be greatly appreciated.

    QUERY -

    CREATE TABLE show (thisId INT (11) not null , name VARCHAR (255) not null , category VARCHAR (255) not null , revenue TEXT not null , expenses TEXT not null , traffic TEXT not null , link VARCHAR (255) not null , comments TEXT not null , price VARCHAR (255) not null , PRIMARY KEY (thisId), UNIQUE (thisId))


    Thanks,

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm guessing that it's the use of a reserved word. I'm not entirely sure, but either "name" or "link" might possibly be reserved names.
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Hartmann,

    Randem is right. This is mostly because we use reserved words as field names. When I usually get stuck with this kind of problem, what I do is add 1 in front of each field name. If it works, then I start removing 1 from each field one by one. This way I know the field name which is a reserved word.

    Hope that helps!


    -Omair
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  4. #4
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you could tell us what the error is, it would help emmensely.

    remove the UNIQUE( thisID) as it is redundant and wasteful.

  5. #5
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Ok I redid the query and still get an error....

    Revamped QUERY-

    CREATE TABLE show (id INT (11) not null , siteName VARCHAR (255) not null , siteCat VARCHAR (255) not null , siteRev TEXT not null , siteExp TEXT not null , siteTraffic TEXT not null , siteLink VARCHAR (255) not null , siteComment TEXT not null , sitePrice VARCHAR (255) not null , PRIMARY KEY (id))

    ERROR-
    MySQL said: You have an error in your SQL syntax near 'show (id INT (11) not null , siteName VARCHAR (255) not null , siteCat VARCHAR' at line 1

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,325
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    it doesn't like the table name "show"

    change that to something else and it works
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello r937,

    It works like a charm now. Hartmann, it was the table name that was creating all this mess


    -Omair
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  8. #8
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Yeah it works now!

    Thanks for the help everyone...
    Man I love this community!

  9. #9
    SitePoint Wizard Goof's Avatar
    Join Date
    Feb 2001
    Location
    Pittsburgh, PA
    Posts
    1,154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know about MySQL, but in MS based databases you could probably just put [] around the fieldname (i.e. to create a field called "show" access it as "[show]").

    Maybe that will help,
    Goof
    Nathan Rutman
    A slightly offbeat creative.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •