| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1215 人关注过本帖
标题:[求助]如何替换掉非法字符,我在论坛上没有搜索到就来请教了
取消只看楼主 加入收藏
redmangame
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2004-8-23
收藏
 问题点数:0 回复次数:3 
[求助]如何替换掉非法字符,我在论坛上没有搜索到就来请教了

[求助]如何替换掉非法字符,我在论坛上没有搜索到就来请教了
高手可以举例吗


还有就是替换非法字符的代码一般是放在处理信息的文件里还是放在输出信息的文件里呢
新手上路问题多多

搜索更多相关主题的帖子: 字符 搜索 
2006-01-22 20:53
redmangame
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2004-8-23
收藏
得分:0 
太深傲了,天啊SAVE。ASP
<%
function filtrate(con,length)
length=Cint(length)
con=replace(con,"'","''")
con=replace(con,chr(34),"""")
con=replace(con,"&","&amp;")
con=replace(con," ","&nbsp;&nbsp;")
con=replace(con,"<","&lt;")
con=replace(con,">","&gt;")
if len(con)>length then
con=left(con,length)
end if
filtrate=con
end function
%>
<%
dim title,con
title=request.form("title")
con=request.form("con")
if trim(title)="" or trim(con)="" then
response.write"所填标题和内容不能为空"
end if
if len(request.form("title"))>5 or len(request.form("con"))>200 then
response.write"所填标题和内容过长"
end if
set rs= Server.CreateObject("adodb.recordset")
sql= "select * from guestbook"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("con")=con
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write("成功<A HREF=list.asp>返回</A>")
%>
这样吧

我是菜鸟
2006-01-23 17:46
redmangame
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2004-8-23
收藏
得分:0 

那个是什么 这样写对吗
<%
function con(contentTemp,length)
length=Cint(length)
contentTemp=replace(contentTemp,"'","''")
contentTemp=replace(contentTemp,chr(34),"""")
contentTemp=replace(contentTemp,"&","&amp;")
contentTemp=replace(contentTemp," ","&nbsp;&nbsp;")
contentTemp=replace(contentTemp,"<","&lt;")
contentTemp=replace(contentTemp,">","&gt;")
if len(contentTemp)>length then
contentTemp=left(contentTemp,length)
end if
com=contentTemp
end function
%>
<%
dim title,con
title=request.form("title")
con=request.form("con")
if trim(title)="" or trim(con)="" then
response.write"所填标题和内容不能为空"
else
set rs= Server.CreateObject("adodb.recordset")
sql= "select * from guestbook"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("con")=con
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write("<A HREF=list.asp>返回</A>")
end if
%>


我是菜鸟
2006-01-24 21:27
redmangame
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2004-8-23
收藏
得分:0 
错误的原因是没有引用,看了几天的代码总算给发现了,哈哈


strSTR = LCase(strSTR)
strSTR = Replace(strSTR,"'","")
strSTR = Replace(strSTR,"*","")
strSTR = Replace(strSTR,"?","")
strSTR = Replace(strSTR,"(","")
strSTR = Replace(strSTR,")","")
strSTR = Replace(strSTR,"<","")
strSTR = Replace(strSTR,">","")
strSTR = Replace(strSTR,".","")
strSTR = Replace(strSTR,"and","")
strSTR = Replace(strSTR,"exec","")
strSTR = Replace(strSTR,"insert","")
strSTR = Replace(strSTR,"delete","")
strSTR = Replace(strSTR,"update","")
strSTR = Replace(strSTR,"select","")
strSTR = Replace(strSTR,"count","")
strSTR = Replace(strSTR,"master.","")
strSTR = Replace(strSTR,"%20from","")
strSTR = Replace(strSTR,";","")
strSTR = Replace(strSTR,"mid","")
strSTR = Replace(strSTR,"chr(37)","")
strSTR = Replace(strSTR,"=","")
strSTR = Replace(strSTR,"set","")

[此贴子已经被作者于2006-1-25 15:20:57编辑过]


我是菜鸟
2006-01-25 15:20
快速回复:[求助]如何替换掉非法字符,我在论坛上没有搜索到就来请教了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011195 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved