Reputation: 138
The value for a field (phone number) isn't being correctly entered into the database. That is, the value seems to change once it's entered.
The phone number has a max limit of 11 characters. In the HTML form, I set the 4 initial defaults characters to 1876 - Jamaica's area code.
<tr>
<td>Phone:</td>
<td><input type="text" name="phone" maxlength="11" value="1876" onkeypress="return isNumberKey(event)"/></td>
</tr>
Then, on the php side:
$phone = $_POST['phone'];
All other values in the field are being entered correctly.
Where did I go wrong?
UPDATE:
In the MySQL table, the column data type is an int.
It's inserted using this query:
$query = "INSERT INTO users (id, first_name, last_name, date_of_birth, email, phone)
VALUES ('$id','$first_name','$last_name','$encrypted_dob','$email','$phone')";
For example, I tried entering, say, 3025009 and it's storing some random value like 2147483647.
Upvotes: 2
Views: 1563
Reputation: 917
It is a problem of datatype signed int which is able to store maximum 2147483647 value in it if you try to store larger value then limit then it will store datatype's maximum limit which is 2147483647. so please use appropriate datatype to store integer value. some references are follows which may fulfill your requirement.
datatype largest value
bigint unsigned 18446744073709551615
bigint signed 9223372036854775807
int unsigned 4294967295
Upvotes: 3
Reputation: 2031
its problem of integer size you have to change data type size "int" to "bigint" then you can get correct value try this it works
Upvotes: 2