I am now using a unique index on multiple columns to prevent duplicate rows. However, I never did find a good reason on the web as to why duplicates happen in the first place. Is it something with my hosting company?

Can you help?

RichardAskew
—
2013-02-12T11:58:37Z —
#2

Have you got any code you can share?

guido2004
—
2013-02-12T12:10:27Z —
#3

Duplicates happen when you insert the same data more than once in your database.It has nothing to do with the hosting, and everything with your code.

KyleWolfe
—
2013-02-12T14:31:30Z —
#4

In the previous thread, we said we needed to see how you are populating the data. The problem is with some application logic that is staging your data for insert. The problem is not going to be with your hosting company.

What Rudy is saying, is that as the developer, you need to decide if this is the behavior that you want. Sure, this will silence your errors, but are you ok with not being notified on those errors.

Jeff_Mott
—
2013-02-12T18:45:40Z —
#12

busboy said:

In the meantime, should I just use insert IGNORE to prevent error messages when the unique index sets an error message?

This will hide the symptom, but not fix the problem.

The problem is that somewhere in your code, you're inserting twice. If you post all your code, then we could probably help you spot the issue.

busboy
—
2013-02-12T20:06:12Z —
#13

Ok, here is the code that processes the form data. I'm not sure how to paste code in here so that it lines up the same way it looks in CODA. As you will see, there is only place where code is inserted into the notifications table, which comprises the email that thanks the author for submitting a new entry. And that particular code is the one that frequently produces duplicates.

Wow, how did you straighten up my code? Your version of it looks better than mine. The code looks perfect in CODA2, which is what I use to develop my website. But I don't know how to paste the code into WYSIWYG html editor without it messing up the formatting.

Ugh!

r937
—
2013-02-12T20:34:40Z —
#16

busboy said:

Wow, how did you straighten up my code?

using search and replace in a text editor to remove all those COLOR and FONT tags and replace tabs with spaces

Jeff_Mott
—
2013-02-12T20:41:10Z —
#17

I don't know how it happened, but the code that r937 posted doesn't look anything like the OP's code. And I don't mean just the formatting...

Busboy, you need to try posting readable code. What you posted seems to be missing an awful lot of newlines. Try using attachments if you can't get copy-paste to work. Also, this definitely doesn't look like all your code. It looks like you copied just a portion from the middle of your script. If the small portion you choose to show doesn't contain the bug you're trying to find, then obviously none of us will be able to help.

Jeff_Mott
—
2013-02-12T20:50:27Z —
#18

Looks like SitePoint might be partly to blame for the bad formatting and the missing content.