关于投票检查ip地址是否已存在的问题

zxlh 2005-01-17 10:20:19
我的代码
<!-- #include file="conn.asp"-->
<% IP=Request.ServerVariables("REMOTE_ADDR") %>
<%
dim rs
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "select * from book where ip="&ip,conn,1,1
if not rs.eof then
if DateDiff("h",rs("时间"), now())<1 then
response.write "<script>alert('您已经投过票了,请不要重复投票');history.back();</script>"
else
SQL="update [book] set 时间=now() where ip=ip"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open SQL,conn,3,3
Dim ID,II
ID=Request.Form("SC004269")
II=Split(ID,",")
for i=0 to ubound(II)
//response.write II(i)
sSQL ="update [vote] set 票数=票数+1 where id="&II(i)
response.Write("<br> <br> <br> <div align='center'><font color='#990000' size='4'><b>数据写入成功!</b></font> ")
Conn.Execute(sSQL)
next
end if
else
SQL="select * from book"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open SQL,conn,3,3

rs.AddNew
rs("ip")=ip
rs("时间")=now()
rs.Update

%>
<%
Dim ID2,II2
ID2=Request.Form("SC004269")
II2=Split(ID2,",")
for i=0 to ubound(II2)
//response.write II2(i)
sSQL ="update [vote] set 票数=票数+1 where id="&II2(i)
response.Write("<br> <br> <br> <div align='center'><font color='#990000' size='4'><b>数据写入成功!</b></font> ")
Conn.Execute(sSQL)
next
end if
%>

运行时的错误:
Microsoft JET Database Engine error '80040e14'

Syntax error in number in query expression 'ip=219.232.0.4'.

/vote/votes.asp, line 6

我用的是access库 ip 的数据类型是文本
...全文
100 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
whb147 2005-01-17
  • 打赏
  • 举报
回复
SQL="update [book] set 时间=now() where ip='"&ip&"'"
whb147 2005-01-17
  • 打赏
  • 举报
回复
ip是字符型的,需要用单引号'
rs.open "select * from book where ip='"&ip&"'",conn,1,1
ygjwjj 2005-01-17
  • 打赏
  • 举报
回复
rs.open "select * from book where ip='"&ip&"'",conn,1,1
.....
SQL="update [book] set 时间=now() where ip='"&ip&"'"
jingxiaoping 2005-01-17
  • 打赏
  • 举报
回复
rs.open "select * from book where ip="&ip,conn,1,1

将以上语句改为
rs.open "select * from book where ip='"&ip&"'",conn,1,1

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧