Hi,
I’ve had a look through the previous posts and cannot find any solution to a problem I am having when submitting Form values to a mySql database
I have a form which submits a playerid, date and points.
I have a unique index on the database table which says that playerid and date must be unique so a playerid can only have one entry per date. This works well when submitting a form but I’ve run into a problem where if i’m submitting say 10 values and a duplicate entry is made for value 5.
The first four values are inserted but the fifth is not and an error message is returned.
I want this to work differently in that I check all form values before I Insert and if ANY duplicates found NO inserts should executed.
What would be the most effecient way of checking in this case ?
Can I run one Select statement to check all values in Query String before I insert ?
My code is
$sql = "INSERT into " .$tbl_name. " (points,date,playerid)
values (1000,".$date.",".$_GET['1']."),
(750,".$date.",".$_GET['2']."),
(600,".$date.",".$_GET['3']."),
(500,".$date.",".$_GET['4']."),
(450,".$date.",".$_GET['5']."),
(400,".$date.",".$_GET['6']."),
(300,".$date.",".$_GET['7']."),
(200,".$date.",".$_GET['8']."),
(100,".$date.",".$_GET['9']."),
(50,".$date.",".$_GET['10'].")";
mysql_select_db($db, $conn);
if (mysql_query($sql,$conn))
echo "<br/>Tournament Points Saved in Database";
else
die ('There was a problems saving the points');
thanks in advance for any advice.