Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email email@example.com
From: Les Fletcher (lesaffinitycircles.com)
Date: Fri Mar 14 2008 - 14:04:30 CDT
I am having some issues with some integer fields and string input. The
table setup is the following:
| Field | Type | Null | Key | Default | Extra |
| intfield1 | smallint(6) | YES | | 0 | |
| intfield2 | smallint(6) | YES | | NULL | |
| intfield3 | smallint(6) | YES | | NULL | |
I have values coming into the database from an HTML form select box.
The default value from the select box is an empty string if nothing is
chosen. So we have an update statement that looks like the following:
UPDATE table SET intfield1='', intfield2='', intfield3='' WHERE ...;
This will then set everything to be 0's. Know, I know that there should
probably be better preprocessing before going to the database, but this
just brought to my attention this issue.
It seems to me that if the value that is being set is invalid for the
field it should set it to NULL or at least the default value for the
field instead of 0. Why is it set to 0 regardless?
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql