piyush23424 Posted March 28, 2010 Share Posted March 28, 2010 i am saving a 10 digits numbers(1234567890) in the database. it's working fine but when number starts with leading zero. then only nine digits gets saved in the database(excluding leading zero) and i am getting this problem when number starts with zero. Please help me Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/196789-coding-help/ Share on other sites More sharing options...
teamatomic Posted March 28, 2010 Share Posted March 28, 2010 try varchar or char HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/196789-coding-help/#findComment-1033056 Share on other sites More sharing options...
zeodragonzord Posted March 28, 2010 Share Posted March 28, 2010 If you need a leading zero, you must store it has characters, not integers. As teamatomic says, CHAR or VARCHAR should work, though if you're expecting 10 numbers always, then use CHAR. Link to comment https://forums.phpfreaks.com/topic/196789-coding-help/#findComment-1033065 Share on other sites More sharing options...
jmajeremy Posted March 28, 2010 Share Posted March 28, 2010 Indeed, if you use an INT type field, then it will automatically try to convert it to a basic number, which means truncating any leading zeros. If you want to maintain the integrity of it as a string you should use a CHAR, VARCHAR or even TEXT type field. Link to comment https://forums.phpfreaks.com/topic/196789-coding-help/#findComment-1033066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.