晚上所有,我有一个语法sql错误的问题
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where username = danny (name, url, banner, description, sponsor, date, password)' at line 1
这是我的代码
$query = "UPDATE websites where username = $login_session (name, url, banner, description, sponsor, date, password) VALUES ('$n', '$b', '$d', '0', now(), SHA('$p'))";
答案 0 :(得分:3)
您的MySQL查询错误,如错误所示,请查看手册。
在UPDATE
中你不能像table(field,field1) values('value','value1')
一样使用INSERT
,你也使用field='value', field1='value1'
,WHERE
应该在最后,正确的顺序是查询+其中+订单+限制。 MySQL并不灵活。
答案 1 :(得分:2)
那是因为您的UPDATE
语句语法错误。检查MySQL documentation for proper UPDATE syntax。我认为你打算做INSERT
而不是
INSERT INTO websites (name, url, banner, description, sponsor, date, password)
VALUES ('$login_session', '$n', '$b', '$d', '0', now(), SHA('$p'))
修改强>
我认为这就是你的目标
UPDATE websites SET name = '$n',
url = '$b',
banner = '$d',
description = '0',
sponsor = 'some_value_here',
date = now(),
password = SHA('$p')
where username = '$login_session';