Welcome Guest, Not a member yet? Register   Sign In
Numbers not inserting correctly into database?
#1

[eluser]RyanH[/eluser]
For some reason I can't get phone numbers to insert into the database correctly. It's just in XXXXXXXXXX format, no dashes or anything and no matter what number I enter, it converts it into some other number. The database field type is INT and from the controller file:
Code:
$rules['phone'] = "numeric|min_length[10]|max_length[10]|trim";

// This is what's in the array that I insert into the database:

'phone' => $this->validation->phone,
I should note that everything else inserts just fine but this keeps getting converted into some odd 10 digit number. Any clue why?
#2

[eluser]xwero[/eluser]
what kind of int field is it?
#3

[eluser]RyanH[/eluser]
What do you mean what kind of INT field is it? It's a regular INT field, nothing else. The default says int(11).
#4

[eluser]Seppo[/eluser]
Check the $this->db->last_query() return after inserting the value to find out if it´s a problem on the query or on the storage.
#5

[eluser]xwero[/eluser]
i think you should use a bigint because the range could be too narrow. mysql fieldtypes
#6

[eluser]RyanH[/eluser]
[quote author="xwero" date="1200894820"]i think you should use a bigint because the range could be too narrow. mysql fieldtypes[/quote]That fixed it, thanks! I didn't even think about the fact that it could be approaching the limit and in fact, the limit was the number it was converting it to. Thanks for the help! Smile
#7

[eluser]xwero[/eluser]
FYI i've just changed the exact_count method of the MY_Validation class in the wiki. Now it works for strings and arrays so you don't have to use min_ and maxlength




Theme © iAndrew 2016 - Forum software by © MyBB