查询表达式中存在语法错误(缺少运算符)
我知道这是一个常见错误,但我仍然无法自己解决。 我想做的是有一个名为 status 的 SELECT 项目,它允许用户选择他们的就业状态,我只想获取结果并更新 user_table(访问文件)状态单元格。 任何答复将不胜感激!
代码如下:
<!--#include file="../conn/conn.asp"-->
<%
id=request.QueryString("id")
status=request.Form("status")
sql="select * from user_table where id="&id
set rs=conn.execute(sql)
sql="update user_table set Status='"+status+"' where id="&id
'response.Write sql
conn.execute(sql)
conn.close
response.Write "<script>alert('Change Sucessful!');</script>"
set conn=nothing
response.end()
%>
I know it is a common error, but I still can't solve it myself.
What I am trying to do is I have a SELECT item called status that allow the user to choose their employment status, I want to simply get the result and update the user_table(access file) status cell.
Any reply will be greatly appreciated!
The Code is below:
<!--#include file="../conn/conn.asp"-->
<%
id=request.QueryString("id")
status=request.Form("status")
sql="select * from user_table where id="&id
set rs=conn.execute(sql)
sql="update user_table set Status='"+status+"' where id="&id
'response.Write sql
conn.execute(sql)
conn.close
response.Write "<script>alert('Change Sucessful!');</script>"
set conn=nothing
response.end()
%>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您可能遇到 conn.execute(sql) 以及 response.end() 问题
要修复它,您需要执行以下任一操作:
或
但是,是的,您应该遵循发布的其他评论,因为您的技术存在安全问题。您应该考虑将其更改为使用参数:
I think you may be having a problem with conn.execute(sql) as well as response.end()
To fix it, you need to do either:
or
But, yeah, you should follow other comments posted as your technique has security issues. You should consider changing it to use parameters:
我猜 conn.asp 让 conn 保持打开状态?否则你需要打开它。另外,当您取消注释 response.write sql 行时会显示什么?
而且,你肯定会向黑客开放自己。您需要“清理”来自 request.form 或 request.querystring 的任何内容(至少使用
replace(..., "'", "''")
,或者更好的是,使用存储过程而不是直接的 sqlI'm guessing conn.asp leaves conn open? otherwise you need to open it. Also, what shows when you uncomment the response.write sql line?
And, you are definitely opening yourself to hackers. You need to 'clean' anything that comes from a request.form or request.querystring (with at the very least, a
replace(..., "'", "''")
, or much better, use stored procedures instead of straight sql