如何解决意外的文件结尾错误

我的 PHP 文件有一些问题,它的目的是将游戏中传递的步骤放在我的数据库中,但是当我尝试提交表单时,它返回了这个错误, Parse error: syntax error, unexpected end of file in /***/**********/****/********/WWW/Page_Administrateur/InsertionEtape.php on line 31


这是我的代码:


<?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";


?>

我该如何解决这个问题?


呼如林
浏览 189回答 1
1回答

互换的青春

您在循环内使用标题尝试评论&nbsp; &nbsp; for ($i=1; $i <= $nbEtapes; $i++) {&nbsp; &nbsp; &nbsp; &nbsp; echo "etape".$i;&nbsp; &nbsp; &nbsp; &nbsp; $DescriptionEtape=$_POST['NomEtape_'.$i];&nbsp; &nbsp; &nbsp; &nbsp; $NomEtape=$_POST['DescriptionEtape_'.$i];&nbsp; &nbsp; &nbsp; &nbsp; $req= "INSERT INTO `Etape` VALUES ('".$NomEtape."','".$DescriptionEtape."');";&nbsp; &nbsp; &nbsp; &nbsp; try {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $dbh->query($req);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Etape Ajouté";&nbsp; &nbsp; &nbsp; &nbsp; } catch (\Exception $e) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo $e;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; //header('Refresh: 50; URL=FormulaireInsertion.php');&nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP