PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 20, 2022

[FIXED] First 0 disappearing?

 February 20, 2022     mysql, php, phpmyadmin, sql     No comments   

Issue

How do I tell phpmyadmin, MySQL to allow the first 0 in front of a phone number for example ? (Not a zero fill)

  • When I try to put a zero in front of it (in phpmyadmin), it removes it automatically.
  • When I submit my form number with the 0 specified in front of the number it doesn't add it.

Is there a workaround or something ?


Solution

The INT datatype in mysql stores just that, an integer. As you would expect with the integer datatype in any programming language, the database engine trims off any leading zeros and rounds any decimal points, making it inappropriate for storing phone numbers.

If the number of digits in the phone number is always the same, use the datatype CHAR(length) instead, or if it's not use the datatype VARCHAR(max_length). These will store the exact value entered rather than an integer value.



Answered By - Bad Wolf
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing