mandrill Posted September 29, 2006 Share Posted September 29, 2006 I'm trying to store mobile phone numbers in a database as the VARCHAR data type but they keep getting stored as 2147483647. There's no problems with landline numbers (which start with 01 in my country) but mobile numbers (07etc.) seem to be problematic. Is there anyway I can force MySQL to store it as a string rather than an integer? I've tried changing the data type (All the INTs unsigned with zerofill, VARCHAR, CHAR, all the TEXTS, and the various BLOBs) and it always stores them as 2147483647. Any advice would be most appreciated as I've been tearing my hair out over this for the last two days. Link to comment https://forums.phpfreaks.com/topic/22500-not-storing-mobile-numbers-properly/ Share on other sites More sharing options...
fenway Posted September 29, 2006 Share Posted September 29, 2006 You should have no issue at all with leading zeros on a VARCHAR column. Link to comment https://forums.phpfreaks.com/topic/22500-not-storing-mobile-numbers-properly/#findComment-100971 Share on other sites More sharing options...
mandrill Posted September 29, 2006 Author Share Posted September 29, 2006 Exactly. Which is what is so baffling. Link to comment https://forums.phpfreaks.com/topic/22500-not-storing-mobile-numbers-properly/#findComment-101060 Share on other sites More sharing options...
printf Posted September 29, 2006 Share Posted September 29, 2006 Are you sure it going into the database, I mean it not your scripting doing it!me! Link to comment https://forums.phpfreaks.com/topic/22500-not-storing-mobile-numbers-properly/#findComment-101138 Share on other sites More sharing options...
fenway Posted September 29, 2006 Share Posted September 29, 2006 Good point... if it's being stored a weakly typed variable, and not explicitly as a string, you could just get the numerical equivalent. Link to comment https://forums.phpfreaks.com/topic/22500-not-storing-mobile-numbers-properly/#findComment-101165 Share on other sites More sharing options...
mandrill Posted September 30, 2006 Author Share Posted September 30, 2006 I went through the code with a fine toothed comb and found this:[code]$insertSQL = sprintf("INSERT INTO customers (CustomerNumber, Title, Address, Surname, WorkNumber, HomeNumber, MobileNumber, Notes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($custID, "text"), GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['address'], "text"), GetSQLValueString($_POST['surname'], "text"), GetSQLValueString($_POST['worknumber'], "int"), GetSQLValueString($_POST['homenumber'], "int"), GetSQLValueString($_POST['mobilenumber'], "int"), GetSQLValueString($_POST['notes'], "text"));[/code]I feel like an idiot. I changed the int's to text's and now it works fine. Thanks anyway :) Link to comment https://forums.phpfreaks.com/topic/22500-not-storing-mobile-numbers-properly/#findComment-101530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.