1

I have some issue with my PHP file it's meant to put steps passed in a game on my database but when I try to submit my form it return me this error, Parse error: syntax error, unexpected end of file in /***/**********/****/********/WWW/Page_Administrateur/InsertionEtape.php on line 31

here's my code:

<?php
include('../connexion.inc.php');
?>
<?php
if (isset($_POST["quantity"]) && $_POST["quantity"] != 0 && $_POST["quantity"] != "") {
$nbEtapes=$_POST['quantity'];
echo $nbEtapes;
  for ($i=1; $i <= $nbEtapes; $i++) {

    echo "etape".$i;
    $DescriptionEtape=$_POST['NomEtape_'.$i];
    $NomEtape=$_POST['DescriptionEtape_'.$i];
    $req= "INSERT INTO `Etape` VALUES ('".$NomEtape."','".$DescriptionEtape."');";
    try {
      $dbh->query($req);
      echo "Etape Ajouté";
    } catch (\Exception $e) {
      echo $e;
    }
    header('Refresh: 50; URL=FormulaireInsertion.php');
  }
}else {
  echo "aucune étapes ajouter car aucune étape n'a été entrée";
  header('Refresh: 2; URL=FormulaireInsertion.php');
}
echo "done";

?>

how can I solve this ?

lo pi
  • 53
  • 7
  • I cannot reproduce this error. It parses fine here. I don't think the header inside the loop, although not correct, causes the problem. Do you care about the security of your game? – KIKO Software May 19 '19 at 09:51

1 Answers1

0

you are using header inside the loop try commenting

    for ($i=1; $i <= $nbEtapes; $i++) {

        echo "etape".$i;
        $DescriptionEtape=$_POST['NomEtape_'.$i];
        $NomEtape=$_POST['DescriptionEtape_'.$i];
        $req= "INSERT INTO `Etape` VALUES ('".$NomEtape."','".$DescriptionEtape."');";
        try {
          $dbh->query($req);
          echo "Etape Ajouté";
        } catch (\Exception $e) {
          echo $e;
        }
        //header('Refresh: 50; URL=FormulaireInsertion.php');
    }
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107