asp中将有双引号标题入库的方法
(编辑:jimmy 日期: 2024/11/27 浏览:3 次 )
复制代码 代码如下:
title=request("title")
title=replace(title,"chr(34)","""")
asp里出现双引号时 要改成两个双引号
asp将单引号替换为双引号
有网友反应将单引号'换成双引号",用replace(string,"'",""")会出现语法错误
正确的写法应该是replace(string,"'","""")
或:
replace(string,chr(39), chr(34))
复制代码 代码如下:
Function EChar(ParaStr)
ParaStr=trim(ParaStr)
ParaStr=replace(ParaStr,chr(39),"'")
ParaStr=replace(ParaStr,chr(34),""")
EChar=ParaStr
End function
Function DChar(ParaStr)
ParaStr=replace(ParaStr,"'",chr(39))
ParaStr=replace(ParaStr,""",chr(34))
DChar=ParaStr
End function
title=request("title")
title=replace(title,"chr(34)","""")
asp里出现双引号时 要改成两个双引号
asp将单引号替换为双引号
有网友反应将单引号'换成双引号",用replace(string,"'",""")会出现语法错误
正确的写法应该是replace(string,"'","""")
或:
replace(string,chr(39), chr(34))
复制代码 代码如下:
Function EChar(ParaStr)
ParaStr=trim(ParaStr)
ParaStr=replace(ParaStr,chr(39),"'")
ParaStr=replace(ParaStr,chr(34),""")
EChar=ParaStr
End function
Function DChar(ParaStr)
ParaStr=replace(ParaStr,"'",chr(39))
ParaStr=replace(ParaStr,""",chr(34))
DChar=ParaStr
End function
下一篇:asp连接access、sql数据库代码及数据库操作代码