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 4 of 4

Thread: numbers

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    numbers

    Is there a method to check that a variable is a number. For ex. for price?

    thanks

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    u can also try this:
    PHP Code:
    if ( !preg_match('/^[0-9\]*$/'$cleaned_for_sql['hp']) ) 
       {      
        echo 
    "HP Number is not Valid Please try again."

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by mmarif4u View Post
    u can also try this:
    PHP Code:
    if ( !preg_match('/^[0-9\]*$/'$cleaned_for_sql['hp']) ) 
       {      
        echo 
    "HP Number is not Valid Please try again."
    Using regular expressions is really not necessary here, and it is a lot slower.


  •  

    Posting Permissions

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