Jump to content

not storing mobile numbers properly...


mandrill

Recommended Posts

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

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 :)

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.