Print Page | Close Window

IF Help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=12788
Printed Date: 29 March 2026 at 11:44pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: IF Help
Posted By: Mattblack
Subject: IF Help
Date Posted: 01 December 2004 at 7:09pm
Hi all, need help desperately.  I need to know why the following code does not work.
 
This one works fine....
if age > 18 and age < 23 then
 
This one doesn't work, even if the data sent is agefrom=18 and ageto=23...
if age > request("agefrom") and age < request("ageto")then
 
I am absolutely baffled.  The first example produces the correct result from the database, and the 2nd example doesn't find any!



Replies:
Posted By: dpyers
Date Posted: 01 December 2004 at 7:31pm
Do a Trim on the request fields and then a Cint.
age = Cint(age)
If age > Cint(Trim(request("agefrom"))) and age < Cint(Trim(request("ageto")))
Not Tested


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mattblack
Date Posted: 01 December 2004 at 9:43pm
ur a star! worked!  And it fixed loads of other problems.  Cheers once again!
 
PS: Why did it work???


Posted By: dpyers
Date Posted: 01 December 2004 at 10:03pm
The CInt converts anything to an integer and the Trim removes any spaces that might come in from a form field.
 
I normally convert to either integer, double, date, or floating-point before any math just to be on the save side - one of the problems with a loosely typed language like VB. Can't tell you what was wrong - lol - only what I do that works.
 
As to why it works, I'm not sure, but strings have a couple of hidden string termination characters and I seem to recall reading somewhere that stuff coming in from a query string had a couple more hidden characters added to them so maybe it's just a matter of cleaning up any hidden garbage. Question
 
EDIT: BTW - instead of request, your should use request.query for stuff coming in from a query string and request.form for stuff passed from a form - makes it a little harder to spoof/hack.


-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net