I am copying a system from an old server to a new(er) one for a company, I had no involvement with the development of the previous system. They have a current (complex) web page that inserts records into a database, and I don’t fully understand it. However, the code of each page and the database settings are exactly the same. When I try to insert an uncompleted form (on my version) I get Field 'invoiceNo' doesn't have a default value whereas submitting the same, uncompleted form on the previous system will create the (incomplete) data.
I have checked the settings for the culprit field, and it is set to Not Null, with a “Null” default value. Both databases are set up the same, so why is the same inserted data being treated differently?
Old MySQL version: 5.0.41-community-nt
New MySQL version: 5.5.20
Old MySQL Admin version: 1.2.12
New MySQL Admin version: 1.2.17
Sorry if it sounds like I don’t have much of a clue what I’m talking about – truth it I don’t as the old system is a stranger to me and it is huge and complex. Can answer any questions though.
It could be that the new server is setup as “strict” or a backwards compatibility break was caused when they introduced the new version.
Your problem is though that the field is expecting “not null” however you are providing null (ie not providing it the data it is setup to expect) if you alter this field to default to “0” then the null fields will default to 0 instead and the data should be added as expected. (But you shouldn’t be submitting “null” if the field is expecting “not null”, so I would look to see the route cause of that before hacking it with default=0!)