From: http://hi.baidu.com/eason_fun/blog/item/f2844a99af3258066e068c86.html
Recently, PHP + MySQL has been used in new projects. N has never touched these two things for a long time, and the result is quite a problem. For a database insert operation, the echo SQL is directly copied to MySQL manager for execution. Worked ~ However, if the insert operation is not executed on the page, mysql_error () is output, which is a 1364 error. The result is as follows:
MySQL 1364 error message: #1364-field "details" doesn' t have a default value.
Generally, the details field does not have a default value. That is to say, we did not assign a value to it, and the default value is not set for this field in the table.
This is something that was developed after mysql5. take a closer look at this section in the my. ini file:Code# Set the SQL mode to strict # SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution" SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution"
If you cannot see my. ini, You can execute the following SQL command. SQL code select @ Global. SQL _mode;
You may suddenly notice: strict_trans_tables (the storage engine enables strict mode and the invalid data value is denied ). This is why 1364 is returned when data is inserted: The default value is not set for the details field.
There are two solutions:
First, set the default value for fields that may not have data during database design.
Second: Set the SQL mode. There are two methods:
(1) Configure My. INI, remove: strict_trans_tables to restart MySQL service my. ini configuration code # Set the SQL mode to strict # SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution" SQL-mode = "no_auto_create_user, no_engine_substitution"
(2), run the SQL command. Note: This Command requires permissions! SQL code set @ Global. SQL _mode = "no_auto_create_user, no_engine_substitution";