I am completely confused on how this could happen, but here are the lines of code that matter: $sent_phone_number = $_POST['phone_number']; $result = mysql_query("UPDATE customer_register SET customer_number='$sent_phone_number' WHERE customer_key='$customer_key'") or DIE(mysql_error()); echo "Your number is ". $sent_phone_number; PHP: I enter my phone number into the form that posts to this PHP file and then this file says my phone number correctly AFTER it's supposed to put it in the database, but for some reason it keeps putting a different number into the database and then outputting the correct one. It always adds the same number to the database, but it's not even close to my number. Does anyone know how this could happen or how to fix it? Thank you very much if you can help
Most probably it happends due to an invalid MySQL field data type - change it to varchar ( just an example ) and see how things change.
I had a similar problem. It seemed to be an error with the Database rather than the programming. I had to change the field type of the phone number to "VARCHAR" rather than "NUMBER" and it worked fine after that. Unfortunately I don't know the reason behind it, just managed to figure out the solution. Hope this helps --Mike
Okay so we've established a solution for the problem but can anybody actually explain why this happens? It baffled me.
This generally happens because of range of the numeric data types in mysql. We generally have tendency to keep it as INT which is not sufficient for mobile numbers. For mobile number, ideal data type would be BIGINT. VARCHAR would ideally require 10 bytes whereas BIGINT takes 8 bytes only. You may check comparisons at below links: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html http://help.scibit.com/mascon/masconMySQL_Field_Types.html
Ahh! Of course! I should have guessed that one I was using a signed INT data type where the maximum value is 2147483647. Every time a user entered a number above this maximum value, it would automatically change to 2147483647. This of course produced problems because the field was a primary key! Thanks mastermunj, reputation added