日期:2014-05-17  浏览次数:21167 次

各位高手帮我看看,有什么好办法可以解决???
我这个是根据request( "remote_addr ")所获得的IP到数据库查地址,然后返回城市到连接上,来实现动态的天气预报效果...
但是现在遇到的一些问题,请各位高手帮忙看看,用什么方法解决最好
还有我的代码有那些不足也请各位指教!!

代码:
<%

dim   sql
        'set   cn=server.Createobject( "ADODB.Connection ")
'cn.open "dsn=ip_id;uid=sa;pwd=sa "
set   cn=Server.Createobject( "ADODB.Connection ")
ip   =   "211.160.165.52 "   'trim(request( "remote_addr "))
cn.open "provider=SQLOLEDB;uid=sa;pwd=sa;database=ip_chengshi;Datasoures=localhost "

set   rs   =   Server.Createobject( "ADODB.Recordset ")
sql= "select   city   from   ip   where   @str   between   startip   and   endip   and   cast(   substring(@str,dbo.StrSite(@str, '. ',2)+1,len(@str)-dbo.StrSite(@str, '. ',2))   as   float)   between   cast(   substring(startip,dbo.StrSite(startip, '. ',2)+1,len(startip)-dbo.StrSite(startip, '. ',2))   as   float)   and     cast(   substring(endip,dbo.StrSite(endip, '. ',2)+1,len(endip)-dbo.StrSite(endip, '. ',2))   as   float)   and   left(@str,dbo.StrSite(@str, '. ',2))=left(@str,dbo.StrSite(startip, '. ',2)) "
rs.open   sql,cn
%>
<iframe   src= "http://www.tianqi123.com/small_page/chengshi_ <%   =rs( "id ")%> .html?c0=red&c1=D96C00&bg=F4FFF4&w=178&h=20&text=yes "   width=178   height=21   marginwidth=0   marginheight=0   hspace=0   vspace=0   frameborder=0   scrolling=no   align=center   id=url> </iframe>
<%
rs.close
set   rs=nothing
cn.close
set   cn=nothing
%>

出现的问题:
错误类型:
Microsoft   VBScript   编译器错误   (0x800A0408)
无效字符
/AAA/SQL_ip.asp,   line   22,   column   34
sql= "select   city   from   ip   where   ' "   @   ip   @   " '   between   startip   and   endip   and   cast(   substring( ' "   @   ip   @   " ',dbo.StrSite( ' "   @   ip   @   " ', '. ',2)+1,len( ' "   @   ip   @   " ')-dbo.StrSite( ' "   @   ip   @   " ', '. ',2))   as   float)   between   cast(   substring(startip,dbo.StrSite(startip, '. ',2)+1,len(startip)-dbo.StrSite(startip, '. ',2))   as   float)   and   cast(   substring(endip,dbo.StrSite(endip, '. ',2)+1,len(endip)-dbo.StrSite(endip, '. ',2))   as   float)   and   left( ' "   @   ip   @   " ',dbo.StrSite( ' "   @   ip   @   " ', '. ',2))=left( ' "   @   ip   @   " ',dbo.StrSite(startip, '. ',2)) "
---------------------------------^


浏览器类型:
Mozilla/4.0   (compatible;   MSIE   6.0;   Windows   NT   5.1;   SV1;   .NET   CLR   1.1.4322)  

网页:
GET   /AAA/SQL_ip.asp  

时间:
2007年7月27日,   上午   09:22:31

------解决方案--------------------
看看!