Jump to content

[SOLVED] data and mysql


MrBillybob

Recommended Posts

Do the query like normal, but catch the error...

 

$query = "INSERT INTO tablename (col1, col2) VALUES ('a', 'b')";

@mysql_query($query);

$error = mysql_errno();

if ($error > 0 && $error == 1022) {
echo "Duplicate entry skipped";
} else if ($error > 0 && $error != 1022) {
echo mysql_error();
} else {
echo "Added!!";
}

 

make sure that column "xy" is a PK or has a unique index.

Link to comment
https://forums.phpfreaks.com/topic/62767-solved-data-and-mysql/#findComment-312491
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.