Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 8th, 2003, 06:45 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Error

I recently downloaded a script. I was installing the tables when one of the tables that I was installing came up with the error:

"MySQL said:


You have an error in your SQL syntax near 'READ char( 3 ) NOT NULL default '', SHOW char( 3 ) NOT NULL default '',' at line 1"

The sql-query is:
CREATE TABLE message (
id int(11) NOT NULL auto_increment,
read char(3) NOT NULL default '',
show char(3) NOT NULL default '',
from varchar(50) NOT NULL default '',
to varchar(50) NOT NULL default '',
subject varchar(50) NOT NULL default '',
msg tinytext NOT NULL,
time timestamp(14) NOT NULL,
readconfirm char(3) NOT NULL default '',
sr char(1) NOT NULL default '',
linkid varchar(32) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;


What's wrong here?

Reply With Quote
  #2  
Old June 8th, 2003, 07:27 PM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 906 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 21 m 10 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Error

read is a mysql keyword. You need to change it so that it's not using any mysql keywords for column names or your putting `column name` around all the column names.

Reply With Quote
  #3  
Old June 8th, 2003, 07:31 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Error

What would you recommend changing it to? I'm not too farmiliar with MySQL, sorry.

Reply With Quote
  #4  
Old June 9th, 2003, 12:14 AM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 906 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 21 m 10 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Error

I doesn't really matter. I'd just use ` (the button to the right of the one on the keyboard).

Reply With Quote
  #5  
Old June 9th, 2003, 07:02 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Error

Like this?:


CREATE TABLE message (
id `int`(11) NOT NULL auto_increment,
read `char`(3) NOT NULL default '',
show `char`(3) NOT NULL default '',
from `varchar`(50) NOT NULL default '',
to `varchar`(50) NOT NULL default '',
subject `varchar`(50) NOT NULL default '',
msg `tinytext` NOT NULL,
time `timestamp`(14) NOT NULL,
readconfirm `char`(3) NOT NULL default '',
sr `char`(1) NOT NULL default '',
linkid `varchar`(32) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;

If not, what would it look like?

Reply With Quote
  #6  
Old June 9th, 2003, 09:46 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 30 sec
Reputation Power: 2
RE: Error

Sliver is trying to tell you that the word "read" is a reserved word in MySQL. That means you can't use it as a database, table, or column name. Here is a list of words you need to stay away from:

http://www.mysql.com/doc/en/Reserved_words.html

Just change your second column name from "read" to something else. You'll have the same problem with your third column, "show", as well. Maybe if you prepend each column name with "msg_". So:
Code:
CREATE TABLE message (
msg_id int(11) NOT NULL auto_increment,
msg_read char(3) NOT NULL default '',
msg_show char(3) NOT NULL default '',
msg_from varchar(50) NOT NULL default '',


etc.....

Reply With Quote
  #7  
Old June 9th, 2003, 10:02 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Error

This is what I ended up submitting:

CREATE TABLE message (
id int(11) NOT NULL auto_increment,
msg_read char(3) NOT NULL default '',
msg_show char(3) NOT NULL default '',
msg_from varchar(50) NOT NULL default '',
msg_to varchar(50) NOT NULL default '',
msg_subject varchar(50) NOT NULL default '',
msg tinytext NOT NULL,
msg_time timestamp(14) NOT NULL,
msg_readconfirm char(3) NOT NULL default '',
msg_sr char(1) NOT NULL default '',
msg_linkid varchar(32) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;

And everything works perfectly now. Thank you both silver and brut for the help. I greatly appreciate it!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT