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
https://forums.phpfreaks.com/topic/296751-csv-uploads-mysql-problem/
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.

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.

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.

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.

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

Archived

This topic is now archived and is closed to further replies.

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