Jump to content

Archived

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

mandrill

not storing mobile numbers properly...

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.

Share this post


Link to post
Share on other sites
You should have no issue at all with leading zeros on a VARCHAR column.

Share this post


Link to post
Share on other sites
Are you sure it going into the database, I mean it not your scripting doing it!

me!

Share this post


Link to post
Share on other sites
Good point... if it's being stored a weakly typed variable, and not explicitly as a string, you could just get the numerical equivalent.

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

×

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.