[英]Error with MySQL syntax using REPLACE INTO
I am getting syntax error with the following statement 我收到以下语句的语法错误
REPLACE INTO users (screenname, token, secret) VALUES( '$screenname', '$token', '$secret' ) WHERE 'screenname' = $screenname
The table has a primary key named id, which auto-increments. 该表具有一个名为id的主键,该主键会自动递增。
据我所知,REPLACE没有位置,您可能需要UPDATE来代替
You need to have a UNIQUE index on screenname
. 您需要在
screenname
上具有UNIQUE索引。
Also your quotes are wrong in the WHERE clause: 同样,您在WHERE子句中的引用是错误的:
WHERE screenname = '$screenname'
I'm going to assume all your variables have been put through mysql_real_escape_string() :) 我将假设所有变量都已通过mysql_real_escape_string()进行了放置:)
try removing both single quotes in the variables of the 尝试删除变量中的两个单引号
values VALUES( '$screenname', '$token', '$secret' ) 值VALUES('$ screenname','$ token','$ secret')
Eg: 例如:
values VALUES($screenname, $token, $secret ) 值VALUES($ screenname,$ token,$ secret)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.