I have code similar to the following:
$sql2 = "ALTER TABLE table ADD UNIQUE(field2, feild3, field4, field5);";
$sql2 .= "INSERT IGNORE INTO table (field1, field2, feild3, field4, field5) VALUES ('$_POST[field1]','$_POST[field2]','$_POST[field3]','$_POST[field4]','$_POST[field5]')";
if (!mysql_query($sql2,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
I have found that I get an error if the table already has two rows which are the same but works well otherwise. I am worried that if I add the duplicates from two different sources that they will both be added to the table and later requests will trigger the error I got earlier because of the two almost identical rows. Is it possible to add two almost identical rows as shown above if the php file is executed at the same time from two different sources?
EDIT: FYI The code is a snippet from a larger program. I am sending data from an android app I am working on to the $_POST fields