标题: 保留字错误 [打印本页] 作者: liyihongcug 时间: 2011-04-07 15:41 标题: 保留字错误 ERROR 1064 (42000): You have an error in your SQL syntax
I try to run the following query. INSERT INTO sections (order,edit,remove,section,type) VALUES('blah','blah','blah','blah','blah');In response I got the the message:
ERROR 1064 (42000): 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 'order,edit,remove,section,type) VALUES('blah','blah','blah','blah','blah')' at line 1.
Any idea to fix ERROR 1064 (42000): You have an error in your SQL syntax;?
Answer No: 51
Your above query contains reserved words in it those are causing error 1064 (42000). ORDER is a reserved word in MySQL and in standard SQL as well. If the column name in the table is ORDER, then put backquotes (`) around the word ORDER when using it as a column name. For Example:INSERT INTO sections (`order`,edit,remove,section,type) VALUES('blah','blah','blah','blah','blah');Best practice: Don't use reserved words for object (table, column,) or to use backquotes beside every column you used like:INSERT INTO sections (`order`,`edit`,`remove`,`section`,`type`) VALUES('blah','blah','blah','blah','blah');作者: liyihongcug 时间: 2011-04-07 16:19
解决思路
配置文件加
default-character-set=utf8
character-set-server=utf8
default-collation=utf8_unicode_ci
不是有错误提示了么?作者: liyihongcug 时间: 2011-04-07 16:24
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to usPosted by wildfeed on July 26, 2007 at 2:52pm
Project: Mailing List Manager
Version: master
Component: Code
Category: bug report
Priority: normal
Assigned: Unassigned
Status: closed (fixed)
Jump to:
Most recent comment
Description
Using module version 1.12 through 1.17, Drupal 5.1, PHP 5.1.6, mysql 5.0.19:
I get the following error when I click on mailing lists tab in user profile
user warning: 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 'WHERE address = 'color.art@mac.com' LIMIT 1' at line 2 query: SELECT 1 FROM WHERE address = 'color.art@mac.com' LIMIT 1 in /Applications/MAMP/htdocs/includes/database.mysql.inc on line 172.
Trying to subscribe to a mailing list gets the following
* user warning: 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 'WHERE address = 'color.art@mac.com' LIMIT 1' at line 2 query: SELECT 1 FROM WHERE address = 'color.art@mac.com' LIMIT 1 in /Applications/MAMP/htdocs/includes/database.mysql.inc on line 172.
* user warning: 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 'WHERE address = 'color.art@mac.com' LIMIT 1' at line 2 query: SELECT 1 FROM WHERE address = 'color.art@mac.com' LIMIT 1 in /Applications/MAMP/htdocs/includes/database.mysql.inc on line 172.
* user warning: 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 'WHERE address = 'color.art@mac.com'' at line 1 query: SELECT 1 FROM WHERE address = 'color.art@mac.com' in /Applications/MAMP/htdocs/includes/database.mysql.inc on line 172.
* user warning: 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 '( hash, address ) VALUES ( '40', 'color.art@mac.com' )' at line 1 query: INSERT INTO ( hash, address ) VALUES ( '40', 'color.art@mac.com' ) in /Applications/MAMP/htdocs/includes/database.mysql.inc on line 172.
* user warning: Table 'wildbase._slog' doesn't exist query: INSERT INTO _slog ( tai, address, fromline, edir) VALUES ( '2007-07-26 09:53:25', 'color.art@mac.com', 'color.art@mac.com', '+') in /Applications/MAMP/htdocs/includes/database.mysql.inc on line 172.
Login or register to post comments
Comments
#1Posted by jerdavis on February 23, 2008 at 3:56am
Status: active » fixed
Some changes were just committed to HEAD which may fix this, also a new development version was generated which should show up shortly. If you can still reproduce the behavior above with this version please let us know.
Login or register to post comments #2Posted by Anonymous (not verified) on March 8, 2008 at 4:12am
Status: fixed » closed (fixed)
Automatically closed -- issue fixed for two weeks with no activity.
Login or register to post comments #3Posted by kwamecg on October 19, 2008 at 11:00am
Title: Error in SQL sytax » You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to us
$wball=mysql_query("SELECT * FROM node_revisions,term_node where node_revisions.vid=term_node.vid AND term_node.tid=3 ORDER BY timestamp DESC limit 6");
this is the query that is giving me the error....
Login or register to post comments #4Posted by HEROESgifted on July 23, 2010 at 2:44pm
How do I fix this error message?
user warning: 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 ' events.field_date_value FROM node n INNER JOIN signup s ON s.nid = n.nid LEFT J' at line 1 query: SELECT n.nid, n.title, n.type, s.status AS signup_status, COUNT(s_l.nid) AS signup_total, s.close_signup_limit AS signup_close_signup_limit, courses.field_date_value, date., events.field_date_value FROM node n INNER JOIN signup s ON s.nid = n.nid LEFT JOIN signup_log s_l ON s.nid = s_l.nid LEFT JOIN content_field_date `courses` ON courses.vid = n.vid LEFT JOIN `date` ON date.vid = n.vid LEFT JOIN content_field_date `events` ON events.vid = n.vid GROUP BY n.nid, n.title, signup_status, signup_close_signup_limit ORDER BY n.title ASC LIMIT 0, 25 in /home2/heroesgi/public_html/modules/signup/signup/includes/admin.signup_administration.inc on line 76.
Login or register to post comments #5Posted by milziv on July 24, 2010 at 11:29am
Hi there,
I have the same error message...any workaround for this issue? Much appreicated.
user warning: 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 '= 424 ) count_alias' at line 3nquery: SELECT COUNT(*) FROM (SELECT send.sid AS sid FROM send send WHERE .nid = 424 ) count_alias in /www/itsmforg/itsmfSerbia/docroot/drupal/sites/all/modules/views/includes/view.inc on line 745.
user warning: 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 '= 424 LIMIT 0, 20' at line 8nquery: SELECT send.sid AS sid, send.timestamp AS send_timestamp, name, uid, send.subject AS send_subject, send.message AS send_message FROM send send WHERE .nid = 424 LIMIT 0, 20 in /www/itsmforg/itsmfSerbia/docroot/drupal/sites/all/modules/views/includes/view.inc on line 771.
Thanks
Login or register to post comments作者: liyihongcug 时间: 2011-04-07 16:25 本帖最后由 liyihongcug 于 2011-04-07 18:11 编辑
反复测试 字符集问题
windows下安装mysql 5.1后在事件查看器里有如下错误信息
‘–default-character-set’ is deprecated and will be removed in a future release. Please use ‘–character-set-server’ instead.
这句话的意思是”default-character-set”在未来版本里将不再使用,而是使用”character-set-server’”来替代,根据提示,我们在my.ini里修改信息,
导入数据时,如果目标数据库或表是UTF-8字符集的,而导入SQL中有中文,可能在最终结果中出现乱码,此时只需在导入的SQL文件第一行加入如下内容 即可。
/*!40101 SET NAMES utf8 */;
以下内容转载:
使用SQLyog工具导出MySQL数据时,当数据量大时,导出 不会错误,但导入时会出 现错误,比如mysql数据库导入SQL文件时出现乱码。
使用命令行导入被导出的数据时会出现如下这类的错误:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_BSD SET_CLIENT */’ at line 1
这是因为命令行模式下不能认出SQL文 件格式造成,可以将SQL文件另存为UTF-8 NO BOM格式,然后进行导入。
另外在导入数据时,如果目标数据库或表是UTF-8字符集的, 而导入SQL中有中文,可能在最终结果中出现乱码,此时只需在导入的SQL文件第一行加入如下内容即可。
/*!40101 SET NAMES utf8 */;
CODE:Error: 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 'DEFAULT CHARSET=gbk' at line 1
Errno.: 1064
一般是编码不符,打开安装文件,看见数据库升级代码,有'DEFAULT CHARSET=gbk'的就可以删除了。
CODE:Error: 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 's XXXXX
Errno.: 1064
比较棘手的问题,一般是数据库代码写入时类型冲突了,如浮点写了汉字就会这样,检查自己的设置,是否该写数字的写了英文或者汉字。如果在插件编写过程中遇到的,就检查数据库语法的正确性。
如果是数据导入,可以用restore.php导入可避免。
CODE:Error: Unknown column 'ff.threadperms' in 'field list'
这种最好解决,一般看见Unknown column提示的,表示你的数据表少了这个表,手动创建即可解决。
CODE:Error: Access denied for user: 'UNKNOWN_USER@localhost' (Using password: YES)
这种问题不知道说什么好~数据库密码用户填错了都还不清楚,咨询空间商。
CODE:Can't DROP 'aaaallowrank'; check that column/key exists
一般是反安装容易出现的,表示该表不存在。其实也没有问题了,不存在的话其实也无须反安装了。
CODE:Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation '='
Errno.: 1267
数据库字符集不符所导致的,请到PHPMYADMIN把数据表的字符集修改下吧。
CODEiscuz! info: MySQL Query Error
User: admin
Time: 2006-4-19 12:32pm
Script: /bbs2/index.php
SQL: DELETE FROM cdb_subscriptions WHERE lastpost<'1145421168'-7776000
Error: Unknown column 'lastpost' in 'where clause'
Errno:1054
An error report has been dispatched to our administrator.
ALTER TABLE cdb_subscriptions ADD lastpost int( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER tid;
CODE:连接出错信息1251:
#1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
解决方法:
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('密码') WHERE Host = 'localhost(主机名)或IP' AND User = '数据库用户名';
mysql> FLUSH PRIVILEGES;
mysql> use mysql
mysql> update user set password=old_password('cnscn');
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1
Current database: mysql