我直接无语了,这个代码为什么提示错误啊????搞了我一晚上了~~
代码:
<!--#include file= "admin_conndb.asp " -->
<%
dim re_username,re_pasword
dim rs,sqlstr
re_username=replace(trim(request.form( "username ")), " ' ", " ")
re_password=replace(trim(request.form( "password ")), " ' ", " ")
if re_username= " " or re_password= " " then
response.Write " <script language=javascript> alert( '登录失败! '); "
response.write "javascript:history.go(-1) </SCRIPT> "
response.end
end if
set rs=server.CreateObject( "adodb.recordset ")
sqlstr= "select * from user where username= ' "&re_username& " ' and password= ' "&re_password& " ' "
rs.Open sqlstr ,conndb,1,1
if rs.eof and rs.bof then
response.write " <SCRIPT language=JavaScript> alert( '用户名或密码不正确! '); "
response.write "javascript:history.go(-1) </SCRIPT> "
response.End
else
session( "username ")=rs( "username ")
session.Timeout=40
response.Redirect "index.asp "
response.end
end if
rs.Close
set rs=nothing
closedb
%>
-------------------------------------
Microsoft JET Database Engine (0x80040E14)
FROM 子句语法错误。
checkadmin.asp, 第 14 行
也就是sqlstr= "select * from user where username= ' "&re_username& " ' and password= ' "&re_password& " ' "
这段代码执行错误,为什么啊???字段名什么都是对的~~
------解决方案--------------------sqlstr= "select * from [user] where (username= ' "&re_username& " ') and (password= ' "&re_password& " ') "
------解决方案--------------------user 是 SQL 中的关键字!