I had this message on a page which I'd used the create dynamic form wizard on and was tearing my hair out. It was appearing the second time I created a new record - the first record used the ID of 0 (which was unallocated), but any subsequent new records generated this error as it started trying to create new records with IDs that were already in use.
The problem I finally isolated was that I hadn't set my primary key to auto-increment (I'd imported an Access database into MySQL using the rather spiffy Navicat tool, and hadn't thought to check it after import). One of those really obvious things, that was too obvious for me to check straight away.
Just thought if I posted this up, it might save someone the hour it cost me to sort out.