Бла*_*ров 4 php mysql syntax-error
我找到了一个非常酷的密码丢失密码,但这一行让我有问题
$r = mysql_query('INSERT INTO `keys` (username,key, vreme) VALUES ("'.$user.'", "'.$acckey.'", "'.$keyexp.'"') or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)
错误
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
Run Code Online (Sandbox Code Playgroud)
egg*_*yal 10
如果标识符包含特殊字符或是保留字,则必须在引用时引用它.(例外:在限定名称中的句点之后的保留字必须是标识符,因此不需要引用它.)
[ deletia ]标识符引号字符是反引号("
`"):Run Code Online (Sandbox Code Playgroud)mysql> SELECT * FROM `select` WHERE `select`.id > 100;如果
ANSI_QUOTES启用了SQL模式,则还允许在双引号内引用标识符: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') ")
Run Code Online (Sandbox Code Playgroud)