I'm building a PHP/HTML front end to a MySQL database.
The table I'm attempting to work with defined with a column that is varchar(15). I can run (without error) an insert statement with a character string that is 20 characters long. The resulting record's column is truncated to 15 characters, but no error is generated.
How do I get this to generate an error?
I know that the interface can do the error checking, but I want to know how to get the database to reject the data as well.
MySQL's fairly forgiving and will try to gracefully accept anything you pass it as best you can, silently converting/truncating/nulling if need be.
Since you don't want that, you need to enable the various "strict" mode options: http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html