Jump to content

CSV uploads mysql problem


moosey_man1988

Recommended Posts

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

 

post-178672-0-73089100-1434024982_thumb.png

 

Thanks in advance for any help given 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by mac_gyver
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.