Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I distinguish between numbers and letters in query string

    hi, I think this is easy but Im very new to php programing,

    i want to + two numbers, this is the code:

    if (is_string($var)) {echo "Enter the right data";} else
    {if (is_string($varr)) {echo "Enter the right data";}}

    $ress = $var + $varr;
    echo "The answer is $ress ";

    the prob is that when a user enters letters instead numbers it displays: "Enter the right data" but it continues doing the other task and ussumes that $var and $varr are = to 0 and + them giving the other message too.

    thanks in advanced
    Arong

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Everything that is sent vie POST/GET is a string. Try using is_numeric() instead.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •