SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How to remember a leading zero?

    I think I read this somewhere but can't find how to solve it now.
    I have a field in my PHP/MySQL form for a mobile number.
    It starts with a zero, but when it ends up in MySQL the zero
    disappears. How do I make it keep that zero?

    Is there a solution to make it remember even if it is starting
    with double zero as well? Just curious.

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have tried to make it as a VARCHAR but now I discovered something else.
    When I put more than 10 numbers it ends up with the following number: 2147483647
    I wrote 1234567812345678 but the above number came up???

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I found out what was wrong. I had put the post as an int instead of a TEXT.
    But still wondering how to make a number with a leading zero to keep the zero/zeros.

  4. #4
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Ukraine
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    let it be float
    or store as text + use special lib for the operation with the long decimals

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use a text type, like CHAR(16). An INT type is definitely not what you want for phone numbers.


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
  •