If you look at insert_record() you'll see that the id is obtained via a SELECT right at the end (because this is most reliable way I could find that works on any database).
However, if you have a table that contains:
id name comment 1 aaa bbb 2 aaa bbb 3 aaa bbbwhere multiple records are exactly the same, then the SELECT may grab another one and thus return the wrong ID.
The simple fix in this case is to add a field with a unique code of some sort, like a timestamp. I always use time(). Timestamps are very useful anyway when reconstructing logs etc.
Cheers!
Martin