moosey_man1988 Posted June 11, 2015 Share Posted June 11, 2015 Hi everyone I have created an upload page which it working very well it uploads data to a database, but im having trouble with phone numbers say I have 7788991100 as a phone number when uploading the phone number from the csv I get the result of 778899110 (its taking off the last 0) Does anyone know how i can stop this? I know i could set the max length to 10 and have the column as zero autofill but that seems to me like a very dodgy way of uploading the phone numbers? here is the layout of my table Thanks in advance for any help given Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 11, 2015 Share Posted June 11, 2015 phone numbers, despite their name, aren't numbers, in a programming sense, and they certainly aren't integers. they are formatted strings consisting of decimal characters. you should be string them as a varchar type. you should also be storing any date values as a DATE data type. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 11, 2015 Share Posted June 11, 2015 Note that I agree with mac_gyver. Is there a reason you're trying to store the phone number as a number? With that said, have you made sure the zero is being lost by MySQL? The reason I ask is that I created a test column as bigint(11) and was able to insert values ranging from -9223372036854775808 to 9223372036854775807. It also didn't have a problem with 7788991100. So maybe something else is going on. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted June 12, 2015 Share Posted June 12, 2015 I'm inclined to think, as @cyberRobot does, that it is something outside MySQL. The (11) is the display size, not the field length - so the value will be stored in it's entirety regardless. that you are only able to store 9 digits of a 10 digit "word" in an 11 digit display field points to it being a different issue. if it was dropping down from 11 to 10 I would suggest that it could be that the signed bit was replacing the least significant bit in the word and as you never have a negative phone number you never see the minus sign showing in that space. But that's not the case, so I expect there is something else at play. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 12, 2015 Share Posted June 12, 2015 (edited) the OP is probably dyslexic (or translated this from a right to left language) and posted his example phone number in reverse. his question/suggestion about using zero fill to 'fix' this would address leading zeros, not trailing ones. Edited June 12, 2015 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted June 12, 2015 Share Posted June 12, 2015 the OP is probably dyslexic (or translated this from a right to left language) and posted his example phone number in reverse. his question/suggestion about using zero fill to 'fix' this would address leading zeros, not trailing ones. It's also arguably much more likely that the OP's making incorrect assumptions about how zero-fill works. I was simply choosing to respond to the info that was presented, nothing more. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 12, 2015 Share Posted June 12, 2015 the OP is probably dyslexic (or translated this from a right to left language) and posted his example phone number in reverse. his question/suggestion about using zero fill to 'fix' this would address leading zeros, not trailing ones. If that's the case, I wonder why it wouldn't strip off both zeros then... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.