Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - IF Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

IF Help

 Post Reply Post Reply
Author
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post Topic: IF Help
    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!
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post 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???
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.


Edited by dpyers - 01 December 2004 at 10:13pm

Lead me not into temptation... I know the short cut, follow me.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.