type mismatch with asp function
I'm getting a type mismatch error with this scrtipt.
I added the third line,
max_length=cint(max_length)
to make sure that the max_length variable would be numerical so that it would work as an argument in the left(function).I got the same error message with and without this line.
What did I do wrong here?
function strEncode(input_str,max_length)
input_str=trim(input_str)
max_length=cint(max_length)
input_str=left(input_str,max_length)
input_str=replace(input_str,",",",")
input_str=replace(input_str,"""",""")
input_str=replace(input_str,"'","'")
strEncode=input_str
end function
sqlstr="SELECT * FROM institutions;"
rs1.Open sqlstr,con,3,3
rs1.AddNew
rs1.fields("date_entered")=date()
input_str=request.form("text_institution_name")
/error here/ input_str=str_Encode(input_str,10) rs1.fields("name")=input_str
rs1.update
rs1.close
Andy Kohlenberg
Jerusalem, Israel
Peter J. Boettcher posted this at 12:56 — 14th September 2001.
They have: 812 posts
Joined: Feb 2000
First off to be on the safe side you should always check your variables for null or "" before you any sort of conversion on them, IsNumeric might be better if you're just trying to detect if the variable is an integer.
I noticed you have this line:
strEncode=input_str
then on the error line you have:
input_str=str_Encode(input_str,10) rs1.fields("name")=input_str
Notice how str_Encode has the "_" ? Maybe that's the problem...
PJ | Are we there yet?
pjboettcher.com
akohl posted this at 13:45 — 14th September 2001.
They have: 117 posts
Joined: Feb 2001
Just found the mistake.
str_Encode does match strEncode
Thanks anyway.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.