Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
KnowledgeWoods Consulting
5,607 PointsStoring Phone no. in mysql DB as int type
I have a contact form on my website. It stores details like name, phone no. , and email. All these are stored in a database. But when i make phone no. column datatype as int it stores a completely different value but in varchar it works fine. For example- When i enter phone no. as 999999999 it stores it as 2147483647 when phone no. column is int.
1 Answer
Chris Shaw
26,676 PointsHi Bhaskar,
Integers aren't designed to handle long unsigned values such as phone numbers as their value can easily exceed the limit set by MySQL servers, it's always best to store values as a varchar when they don't meet the requirements of that column type which in this case is the integer type.
You can read more at http://dev.mysql.com/doc/refman/5.1/en/integer-types.html