Author |
Topic |
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 02:53:18
|
I am trying to add extra checking to some variables in ClassPlaceAd.asp.
I am getting type mismatch error on executing this code when PortalContentID is empty (PortalContentId = Request("PortalContentId")): -------------------------------------------------------------------- if PortalContentId = "" or (PortalContentId > 1000) then ---------------------------------------------------------------- But there is no error when executing this code: ------------------------------------------ if PortalContentId = "" then ------------------------------------------
Any idea whats wrong here?
Microsoft VBScript runtime (0x800A000D) Type mismatch: '[string: ""]' /mysite1/classplacead.asp, line 77
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 02:59:05
|
No, its still error |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 03:05:17
|
Its should be around line 70-80. (Should star with "if catID = "" then" I am actually adding extra checking to this line since I am passing another variable to this page and I need to check for empty, size and Numeric before proccessing.
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 03:17:49
|
The original code is: "if catID = "" then"
I added this checking:
if catID = "" or PortalContentId = "" or PortalContentID > 1000 or catID > 1000 or (Not IsNumeric(PortalContentID)) or (Not IsNumeric(catID))
I hope thats information you need |
Edited by - lsakizada on 24 August 2003 03:18:47 |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 24 August 2003 : 03:22:35
|
did you also use CLng(catID) too? both PortalContentID and catID if they are pulled from a form are actually text values, so you have to convert them to long integer values to be able to compare against a number like 1000. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
|
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 03:29:11
|
Yes,I tried all the combinations,
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 24 August 2003 : 03:33:09
|
try adding just one test at a time to determine which on is actually giving the error. you might also get an error if either of those are empty values, so you might want to do separate if statements instead of grouping them all together. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
|
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 03:37:53
|
I already did it, see the first topic.
This pass: if PortalContentId = "" then
but not this: if PortalContentId = "" or (PortalContentId > 1000) then
or as you suggested
if PortalContentId = "" or (CLng(PortalContentId)> 1000) then
this is a nightmare.. :)
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 24 August 2003 : 03:40:13
|
so is PortalContentID actuall empty? that's probably why you are getting the other error. why don't you start with the isnumeric first (forget checking for an empty value, because it won't be numeric if it is empty) |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
|
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 03:52:26
|
No, its not working either. its seems that this are the two cases that working "if PortalContentId = "" then" or "if PortalContentId = "" or CatID = "" then"
All other cases return mismatch error (including the statement with CLng(...))
|
|
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 04:03:06
|
One more case is working: if Not IsNumeric(PortalContentID)then
but when executing this you get the error bellow
if Not IsNumeric(PortalContentID) or PortalContentID > 1000 then
Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'PortalContentId' /mysite1/classplacead.asp, line 77
Is the any chance that I need to cast the variable ('PortalContentId) before sending it to other page? |
|
|
lsakizada
New Member
USA
90 Posts |
Posted - 24 August 2003 : 04:25:06
|
Hi guys, I am happy. here is the solution (my mistake :)
if catID = "" or catID > "1000" or PortalContentId = "" or PortaContentId > "1000" or (Not IsNumeric(PortalContentID)) or (Not IsNumeric(catID))then
Nikkol, I am realy appreciated your time and your help, regards |
|
|
|
Topic |
|