MySQL:“您的SQL语法中的错误...靠近键..."? [英] MySQL: "error in your SQL syntax ... near key ..."?

查看:84
本文介绍了MySQL:“您的SQL语法中的错误...靠近键..."?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个很酷的密码丢失提示,但是这一行让我很麻烦

I found one very cool scirpt for lost password but this row is making me problems

$r = mysql_query('INSERT INTO `keys` (username,key, vreme) VALUES ("'.$user.'", "'.$acckey.'", "'.$keyexp.'"') or die(mysql_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 'key, vreme) VALUES ("123123", "1ed2f5100a26298a55b2935cbea7d4a0", "1337991670"' at line 1

推荐答案

KEY保留字.如架构对象名称:

如果标识符包含特殊字符或为保留字,则引用时必须 对其进行引用. (例外:限定名称中句点后的保留字必须是标识符,因此无需加引号.)

If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. (Exception: A reserved word that follows a period in a qualified name must be an identifier, so it need not be quoted.)

[ deletia ]

标识符引号是反引号("`"):

The identifier quote character is the backtick ("`"):

mysql> SELECT * FROM `select` WHERE `select`.id > 100;

如果 ANSI_QUOTES SQL模式启用后,也可以在双引号中加上标识符:

If the ANSI_QUOTES SQL mode is enabled, it is also permissible to quote identifiers within double quotation marks:

mysql> CREATE TABLE "test" (col INT);
ERROR 1064: You have an error in your SQL syntax...
mysql> SET sql_mode='ANSI_QUOTES';
mysql> CREATE TABLE "test" (col INT);
Query OK, 0 rows affected (0.00 sec)

因此:

mysql_query("INSERT INTO `keys` (username, `key`, vreme) VALUES ('$user', '$acckey', '$keyexp') ")

这篇关于MySQL:“您的SQL语法中的错误...靠近键..."?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆