I have a bunch of insert querys running and some of them fail with a duplciate entry.

I want to see a log where it says "Error: Duplicate key" and that tells me the EXACT INSERT query that fails so I can see what keys are duplicated.

Thanks

Hello,

Try INSERT IGNORE in place of INSERT and it will ignore the duplicate key errors.

Member Avatar for diafol
mysql_query($sql); //or use mysqli equivalents
if (mysql_errno() == 1062) {
    echo "Duplicate key error: <pre><code>$sql</code></pre>";
}

I went ahead with REPLACE but thank you

And this isnt a PHP question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.