Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query won't run, but not sure why? 1

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

Can anyone suggest why this query won't execute?

Code:
CREATE TABLE games (
  id int(11)    auto_increment,
  nameid char(255),
  name char(255)  ,
  desc char(255)  ,
  time int(10)  DEFAULT '0'  ,
  width int(10)  DEFAULT '0'  ,
  height int(10)  DEFAULT '0'  ,
  cat varchar(255)  ,
  rating decimal(3,2)  DEFAULT '0.00'  ,
  type enum('SWF','extlink','DCR','CustomCode')  DEFAULT 'SWF'  ,
  authorsite varchar(255)  ,
  authorname varchar(255) ,
  gameurl varchar(255)   ,
  code text    ,
  playcount int(10)  DEFAULT '0'  ,
  weeklyplays int(10)  DEFAULT '0'  ,
  flags varchar(255)   ,
  instructions text    ,
  keywords varchar(255)    ,
  disphtml enum('Config','No','Yes')  DEFAULT 'Config'  ,
  disphtmlcode text    ,
  order int(10)  DEFAULT '0'  ,
  active enum('Yes','No')  DEFAULT 'Yes'  ,
  PRIMARY KEY (id)
);

I keep getting 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 'desc varchar(255) , time int(10) DEFAULT '0' , width int(10) DEFAULT '' at line 5

I've tried working it out, but can't see why it won't work :(

TIA

Andy
 
It's probabby because desc is an SQL reserved workd (you use it in order by clauses) You can use reserved workds in MYSQL by enclising it in ticks (which I think is the one on the key to the keft of the 1 ket (on my key board any way)). But really id you can avoid reserved workds so much the better e,g, make your desc description. You also use order towards the end of the table which will trigger the same error.
 
Hi,

Thanks! Got me on the right track. There were actually 4 different fields that needed `` around them:

CREATE TABLE games (
id int(11) auto_increment,
nameid varchar(255),
name varchar(255),
`desc` varchar(255),
`time` int(10) DEFAULT '0' ,
width int(10) DEFAULT '0' ,
height int(10) DEFAULT '0' ,
cat varchar(255) ,
rating decimal(3,2) DEFAULT '0.00' ,
`type` enum('SWF','extlink','DCR','CustomCode') DEFAULT 'SWF' ,
authorsite varchar(255) ,
authorname varchar(255) ,
gameurl varchar(255) ,
code text ,
playcount int(10) DEFAULT '0' ,
weeklyplays int(10) DEFAULT '0' ,
flags varchar(255) ,
instructions text ,
keywords varchar(255) ,
disphtml enum('Config','No','Yes') DEFAULT 'Config' ,
disphtmlcode text ,
`order` int(10) DEFAULT '0' ,
active enum('Yes','No') DEFAULT 'Yes' ,
PRIMARY KEY (id)
);


Stupid thing is - this software is about $600 (my client brought it ages ago, not me) ... and it worked fine before - but it seems a bit of a basic boo-boo that they can't even use non-reserved field names :(

Anyway, thanks again - star coming your way = )

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top