I'm using a PHP script to batch insert data into a MySQL table. How do I make the script skip any queries that throw an error and continue with the next. For example if field slug accepts unique values and I attempt to insert the same value twice it will throw a duplicate entry for key slug error and the script will stop executing.
How can I make it continue to the next statement?
Here a code example:
for ($row = $begin_row; $row <= $highestRow; $row++) {
$sql = sprintf("INSERT INTO ".$dbprefix."terms (name, slug, term_group) VALUES (%s, %s, %s)",
GetSQLValueString($name, "text"),
GetSQLValueString($slug, "text"),
GetSQLValueString(0, "int"));
$result = mysql_query($sql) or die(mysql_error());
}