|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
RE: Error
What would you recommend changing it to? I'm not too farmiliar with MySQL, sorry.
|
|
#4
|
||||
|
||||
|
RE: Error
I doesn't really matter. I'd just use ` (the button to the right of the one on the keyboard).
|
|
#5
|
|||
|
|||
|
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? |
|
#6
|
|||
|
|||
|
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..... |
|
#7
|
|||
|
|||
|
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! |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|