SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: intval for phone number

  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2008
    Posts
    594
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    intval for phone number

    hi

    i used for getting phone number

    PHP Code:
    $phone intval($_POST['phone']); 
    if the number is equal to or more than 10 digits then i get this below number everytime

    Code:
    2147483647
    otherwise its fine for less than 10 digits

    vineet

  2. #2
    From Italy with love bronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    8,609
    Mentioned
    76 Post(s)
    Tagged
    4 Thread(s)

  3. #3
    Hosting Advisor silver trophybronze trophy
    SitePoint Award Recipient cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    2,812
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    The problem you are having is the phone number exceeds the maximum value an integer can hold. A PHP integer can hold a value up to 2147483647.

    You will need to use the is_numeric() or the ctype_digit() function to check if you were given a numeric value.

  4. #4
    SitePoint Evangelist
    Join Date
    Nov 2008
    Posts
    594
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hi

    what should be the column type in database for storing 10 digit numeric phone number

    vineet

  5. #5
    Hosting Advisor silver trophybronze trophy
    SitePoint Award Recipient cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    2,812
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    I personally always use varchar(X) where X is the number of characters you want stored. The reason being, I don't want any leading zeros truncated.

Bookmarks

Posting Permissions

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