屏蔽ip代码问题

eatmoney 2005-04-16 08:43:27
<!--#include file="conn.asp"-->

<%
set rs=server.createobject("adodb.recordset")
sql="select top 1 * from ip"
rs.open sql,conn,1,3



ip_start=request("ip_start")
ip_ary=split(ip_start,".")
ip_start=ip_ary(0)*256*256*256+ip_ary(1)*256*256+ip_ary(2)+ip_ary(3)
ip_end=request("ip_end")
ip_ary=split(ip_end,".")
ip_end=ip_ary(0)*256*256*256+ip_ary(1)*256*256+ip_ary(2)*256+ip_ary(3)

rs.addnew
rs("ip_start")=request.form("ip_start")
rs("ip_end")=request.form("ip_end")
rs.update
response.write("转换成功")
response.end

%>
提示:下标越界: '[number: 0]'

请问这个问题怎么解决?
...全文
139 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
eatmoney 2005-04-16
  • 打赏
  • 举报
回复
改了也不行啊。
Microsoft VBScript 运行时错误 错误 '800a0009'

下标越界: '[number: 0]'

/ip/add_ipok.asp,行 14

出现了这样的提示
menrock 2005-04-16
  • 打赏
  • 举报
回复
双精度都放不下?那你就用文本型咯
eatmoney 2005-04-16
  • 打赏
  • 举报
回复
Provider 错误 '8002000a'

超出当前范围。

/ip/add_ipok.asp,行 18

提示这个错误
menrock 2005-04-16
  • 打赏
  • 举报
回复
rs.addnew
ip_start=request("ip_start")
ip_end=request("ip_end")
rs.update
response.write("转换成功")
response.end
你这样根本就没更新到数据库
rs.addnew
rs("ip_start")=ip_start
rs("ip_end")=ip_end
rs.update
response.write("转换成功")
response.end
eatmoney 2005-04-16
  • 打赏
  • 举报
回复
数字型,字段大小是双精度行。
menrock 2005-04-16
  • 打赏
  • 举报
回复
你数据库的字段是什么类型的?
eatmoney 2005-04-16
  • 打赏
  • 举报
回复
呵呵,不好意思啊
我将才没有看到你的回复啊。
不要怪我哦
希望你能继续回答我下面的问题啊。
eatmoney 2005-04-16
  • 打赏
  • 举报
回复
<!--#include file="conn.asp"-->

<%
set rs=server.createobject("adodb.recordset")
sql="select top 1 * from ip"
rs.open sql,conn,1,3



ip_start=request("192.168.0.1")
ip_ary=split(ip_start,".")
ip_start=ip_ary(0)*256*256*256+ip_ary(1)*256*256+ip_ary(2)+ip_ary(3)
ip_end=request("192.168.0.255")
ip_ary=split(ip_end,".")
ip_end=ip_ary(0)*256*256*256+ip_ary(1)*256*256+ip_ary(2)*256+ip_ary(3)

rs.addnew
ip_start=request("ip_start")
ip_end=request("ip_end")
rs.update
response.write("转换成功")
response.end

%>
我把代码改成这样之后就可以转换了,可是在数据库中并没有转换成双精度的数字而是显示零。请问应该怎么解决?

我去客户值得代码如下:

<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>管理</TITLE>
</HEAD>
<body leftmargin="0" topmargin="0">
<form name="form2" method="post" action="add_ipok.asp">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr height=40>
<td width=100%> · 内容:<font color=red>您目前正在浏览的内容为 [管理 ]</font></td>
</tr>
</table>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr height=30>
<td width=20%> · ip1</td>
<td width=80%><input name="ip_start" type="text" class="input1" size="60" ></td>
</tr>
<tr height=30>
<td width=20%> · ip2</td>
<td width=80%><input name="ip_end" type="text" class="input1" size="60" ></td>
</tr>
</table>
<table border="0" width="600" cellspacing="0" cellpadding="0">
<tr>
<td>   <input type="submit" name="Submit" value=" 立即增加 ">   </td>
</tr>
<tr height=30>
<td></td>
</tr>
</table>
</form>
menrock 2005-04-16
  • 打赏
  • 举报
回复
晕,兄弟你这句话就不厚道了
eatmoney 2005-04-16
  • 打赏
  • 举报
回复
没人回答吗?
menrock 2005-04-16
  • 打赏
  • 举报
回复
先检测IP是否合格
ip_start=request("ip_start")
ip_ary=split(ip_start,".")
if ubound(ip_ary)<>3 then
response.write("非法IP")
response.end
end if
for i=0 to 3
if not isnumeric(ip_ary(i)) or len(ip_ary(i))>3 then
response.write("非法IP")
response.end
end if
next
ip_start=ip_ary(0)*256*256*256+ip_ary(1)*256*256+ip_ary(2)+ip_ary(3)
ip_end=request("ip_end")
ip_ary=split(ip_end,".")
if ubound(ip_ary)<>3 then
response.write("非法IP")
response.end
end if
for i=0 to 3
if not isnumeric(ip_ary(i)) or len(ip_ary(i))>3 then
response.write("非法IP")
response.end
end if
next
ip_end=ip_ary(0)*256*256*256+ip_ary(1)*256*256+ip_ary(2)*256+ip_ary(3)

28,391

社区成员

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

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