CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

屏蔽ip代码问题

楼主eatmoney(无间)2005-04-16 20:43:27 在 Web 开发 / ASP 提问

<!--#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%>&nbsp;·   内容:<font   color=red>您目前正在浏览的内容为   [管理   ]</font></td>  
    </tr>  
  </table>  
  <br>  
  <table   border="0"   width="100%"   cellspacing="0"   cellpadding="0">  
    <tr   height=30>  
      <td   width=20%>&nbsp;·   ip1</td>  
      <td   width=80%><input   name="ip_start"   type="text"   class="input1"   size="60"   ></td>  
    </tr>  
    <tr   height=30>  
      <td   width=20%>&nbsp;·   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>   &nbsp;   <input   type="submit"   name="Submit"   value="   立即增加   ">   &nbsp;   </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

相关问题

  • 如何编写屏蔽IP访问的源代码?
  • 求能限制可访问网址或屏蔽ip的bcb代码 或是vc代码
  • 用javascript如何屏蔽html代码?
  • 急!求屏蔽frameset的js代码!
  • asp求屏蔽右键代码
  • 屏蔽某些IP上网!!!
  • 如何屏蔽parent窗口中事件的代码??
  • 如何在留言板里屏蔽HTML代码????
  • 如何查看屏蔽了右键的网页的源代码?
  • 问题:在asp.net 的DataSet里我怎么屏蔽html代码呀(。

关键词

  • 转换
  • ip
  • start
  • asp
  • ipok
  • updateresponse
  • 错误
  • 提示
  • 转换成功
  • rs

得分解答快速导航

  • 帖主:eatmoney
  • menrock
  • menrock
  • menrock

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo