Telephone Numbers In Fields - How?

Discussion in 'PHP' started by devo10, Jun 5, 2010.

  1. #1
    Hello

    Could somebody please help? I am creating a registration form for my site in php. One of the fields I need to create is for telephone number. Many numbers will need to start with 00. A typical number could be: 00 44 1234 5678.

    I can get my field to accept numbers, but after 6 digits I get an error message and it will not accept 0 or 00 as the first numbers.

    Could you help?

    Thanks in advance
     
    devo10, Jun 5, 2010 IP
  2. Sergey Popov

    Sergey Popov Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you mean you're saving phone numbers to numeric field in the database? I would recommend to use text field for this, especially that you have numbers starting with zero.

    What error message are you getting?
     
    Sergey Popov, Jun 5, 2010 IP
  3. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #3
    It's the spaces, change it to a varchar in the MySQL database.
     
    HuggyEssex, Jun 5, 2010 IP
  4. kidatum

    kidatum Peon

    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    All that or use preg_replace() function to replace any non-digit characters with nothing.
     
    kidatum, Jun 5, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #5
    After 6 digits it wont accept 0's right??
    Then its a Bug script
    Think off a typical number like this 00 44 1204 5600
    If wont accept 0's after 6 digits them how come a use rcan submit it
     
    roopajyothi, Jun 5, 2010 IP
  6. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #6
    Assuming your are storing this in a MySQL database, it sounds like your phone number field is a "SMALLINT" datatype.

    Change this to a varchar and it should fix your problem.

    Also, numbers do not start 00 XXXXXXXXXX. You will either need to store it as a string (use varchar, as above) or have the prefix defined as a seperate field.
     
    lukeg32, Jun 6, 2010 IP
  7. devo10

    devo10 Active Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #7
    Thanks to all of you for taking time to submit your input - it’s really appreciated. I will resolve the problem by just using a text field and preventing symbols etc that may cause problems in the database.

    Many Thanks
     
    devo10, Jun 6, 2010 IP