SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    625
    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 silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 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 Guru
    Join Date
    Nov 2008
    Posts
    625
    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 Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 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
  •