title: Duplicate entry for key 'PRIMARY' - even though it is set to AUTO_INCREMENT
body: <p>Bit of a strange one - I haven't changed the config, database, PHP code for this site for about 8 years. The whole time the guy I made it for has been adding, removing, changing stock with no issue, and suddenly today gets this error:</p>
  <pre><code>Duplicate entry '2541' for key 'PRIMARY'
  </code></pre>
  <p>executing (inserted generic values for the texts):</p>
  <pre><code>INSERT INTO stock (id,title,category,description,price,last_update,sold) VALUES(NULL,'Item name','72','Item description','0',1613723525,'no')
  </code></pre>
  <p>Searching around seemed to suggest this was a common problem when the primary key is not set to auto increment - makes sense. However, checking it out through phpMyAdmin, it definitely is.</p>
  <p><a href="https://i.stack.imgur.com/hMKoG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hMKoG.png" alt="enter image description here" /></a></p>
  <p>Is there something in the index being set to primary rather than unique?</p>
  <p>There are 5 other tables on the database but none are linked (as in hard links through the SQL, PHP handles all the cross-table stuff).</p>
  <p>I checked and indeed there IS an item in the stock table with ID 2541 already. So why is that NULL AUTO_INCREMENT value converting to an existing id?</p>
  <p><a href="https://i.stack.imgur.com/SSEaY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SSEaY.png" alt="enter image description here" /></a></p>
  <p><em><strong>EDIT</strong></em></p>
  <p>I noticed that a table I created more recently (via MySQL Workbench probably) has a different setup for the indexes, with the addition of an <code>id_UNIQUE</code> index - do I need one of these on the stock table that is causing issues?</p>
  <p><a href="https://i.stack.imgur.com/ksWzf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ksWzf.png" alt="enter image description here" /></a></p>