I have a function for turning HTML encoded text back into HTML. It works great normally, but for some reason, I try to use it on some text today, and get the following error:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'UnChkString'
/manage/solutions_delete.asp, line 22
The line I am using this function on is:
<%= UnChkString(solution_desc) %>
The solution_desc
variable is:
<p>Here is a description of what this solution is all about.</p>
The field the database is pulling the solution_desc
from is a text field.
My UnChkString function is:
Function UnChkString(string)
UnChkString = Replace(string,"[%]","%")
UnChkString = HTMLDecode(UnChkString)
End Function
The HTMLDecode function is:
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, "&" , "&")
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "’", Chr(39))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
EDIT
I've even tried:
<%= UnChkString(CStr(solution_desc)) %>
with no luck.
I agree with Anthony's opinion that you should be using Option Explicit at the top of your ASP pages.
I suspect the cause is a missing or malformed include file
I can replicate this with the code below where I either remove
<!--#include file="include-functions.asp"-->
or malform the call by changing it to
<!-#include file="include-functions.asp"-->
include-functions.asp
<%
Function UnChkString(string)
UnChkString = Replace(string,"[%]","%")
UnChkString = HTMLDecode(UnChkString)
End Function
%>
index.asp
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<!--#include file="include-functions.asp"-->
<%
Dim solution_desc
solution_desc = "<p>Here is a description of what this solution is all about.</p>"
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, "&" , "&")
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "’", Chr(39))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
%>
<%= UnChkString(solution_desc) %>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With