屏蔽ip代码问题
<!--#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]'
请问这个问题怎么解决?
问题点数:30、回复次数:11Top
1 楼menrock(教坏细路)回复于 2005-04-16 21:48:22 得分 10
先检测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)Top
2 楼eatmoney(无间)回复于 2005-04-16 22:01:14 得分 0
没人回答吗?Top
3 楼menrock(教坏细路)回复于 2005-04-16 22:04:31 得分 0
晕,兄弟你这句话就不厚道了Top
4 楼eatmoney(无间)回复于 2005-04-16 22:06:37 得分 0
<!--#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>
Top
5 楼eatmoney(无间)回复于 2005-04-16 22:08:33 得分 0
呵呵,不好意思啊
我将才没有看到你的回复啊。
不要怪我哦
希望你能继续回答我下面的问题啊。Top
6 楼menrock(教坏细路)回复于 2005-04-16 22:14:32 得分 0
你数据库的字段是什么类型的?Top
7 楼eatmoney(无间)回复于 2005-04-16 22:22:02 得分 0
数字型,字段大小是双精度行。Top
8 楼menrock(教坏细路)回复于 2005-04-16 22:25:34 得分 10
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
Top
9 楼eatmoney(无间)回复于 2005-04-16 22:36:27 得分 0
Provider 错误 '8002000a'
超出当前范围。
/ip/add_ipok.asp,行 18
提示这个错误
Top
10 楼menrock(教坏细路)回复于 2005-04-16 22:39:55 得分 10
双精度都放不下?那你就用文本型咯Top
11 楼eatmoney(无间)回复于 2005-04-16 22:46:54 得分 0
改了也不行啊。
Microsoft VBScript 运行时错误 错误 '800a0009'
下标越界: '[number: 0]'
/ip/add_ipok.asp,行 14
出现了这样的提示Top




