$teamnameindex = "TeamName" . $n; $tidsvisindex = "tidsVis" . $n; $teamnameindexnew = stripslashes($teamnameindex); $tidsvisindexnew = stripslashes($tidsvisindex); echo $tidsvisindex; $sql = "INSERT INTO Results (ID, TeamName, TeamResult) VALUES ('".$id."','" . $_POST[$teamnameindexnew] . "', '" . $_POST[$tidsvisindexnew] . "')";