我的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";
?>
我该如何解决?
答案 0 :(得分:0)
您在循环内使用标题尝试注释
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');
}