par
le loup solitaire » 24 avr. 2016, 11:04
bonjour,
je ne comprend pas pourquoi cette erreur, pouvez vous m'expliqué, je sais que ça veut dire "variable non défini", mais pourquoi dans le script.
<?php
$reponses = array(
'chx' => array(
'reponse' => 'un',
'mot' => 'po',
'drag' => '___rtable',
'image' => 'img/portable.gif'
) ,
'chx_1' => array(
'reponse' => 'le',
'mot' => 'so',
'drag' => '___l',
'image' => 'img/sol.gif'
) ,
'chx_2' => array(
'reponse' => 'un',
'mot' => 'peau',
'drag' => 'dra___',
'image' => 'img/drapeau.gif'
) ,
'chx_3' => array(
'reponse' => 'un',
'mot' => 'teau',
'drag' => 'pla___',
'image' => 'img/plateau.gif'
) ,
'chx_4' => array(
'reponse' => 'des',
'mot' => 'vau',
'drag' => 'tra___x',
'image' => 'img/panneau.gif'
) ,
'chx_5' => array(
'reponse' => 'de la',
'mot' => 'sau',
'drag' => '___ce',
'image' => 'img/sauce.gif'
) ,
'chx_6' => array(
'reponse' => 'un',
'mot' => 'seau',
'drag' => '____',
'image' => 'img/seau.gif'
) ,
'chx_7' => array(
'reponse' => 'du',
'mot' => 'cho',
'drag' => '___colat',
'image' => 'img/chocolat.gif'
),
'chx_8' => array(
'reponse' => 'une',
'mot' => 'to',
'drag' => '___mate',
'image' => 'img/tomate.gif'
) ,
'chx_9' => array(
'reponse' => 'des',
'mot' => 'chau',
'drag' => '___ssures',
'image' => 'img/chaussure.gif'
)
);
foreach($reponses as $cle => $reponse)
{
if (isset($_POST['correction']))
{
$clic = $_POST[$cle];
if (empty($clic) && empty($clic) != $reponse['mot'])
{
var_dump($clic);
$msg = '<p>veuillez remplir tous les champs</p>';
echo $msg;
}
else
if ($clic == $reponse['mot'])
{
echo '<p style="margin-left:4em;">' . $reponse['mot'] . '</p><p style="margin-left:5em;">'. $reponse['drag'] . '</p><br />';
}
else
if ($clic != $reponse['mot'])
{
$errors = array();
$errors[$cle] = htmlspecialchars($clic);
echo '<article class="content_img"><figure><img src="'. $reponse['image'] .'" alt="" width:"75" height="75" /></figure><p style="color:red;margin-left:4em;"><del>' . $errors[$cle] . '</del><p>'.$reponse['mot'].'</p><p style="text-align:right;margin-left:5em;">'. $reponse['drag'] . '</p></article>';
}
}
}
echo'<br />';
echo'<p style="display:inline-block;margin:2em 0 0 35%;padding:.5em;background:#54d0ce;font-size:1.2em;">Bonnes réponses :'.count($reponse['mot']).' - '.count($errors[$cle]).'/10</p>';
echo'<br /><br />';
?>
merci d'avance
bonjour,
je ne comprend pas pourquoi cette erreur, pouvez vous m'expliqué, je sais que ça veut dire "variable non défini", mais pourquoi dans le script.
[php]<?php
$reponses = array(
'chx' => array(
'reponse' => 'un',
'mot' => 'po',
'drag' => '___rtable',
'image' => 'img/portable.gif'
) ,
'chx_1' => array(
'reponse' => 'le',
'mot' => 'so',
'drag' => '___l',
'image' => 'img/sol.gif'
) ,
'chx_2' => array(
'reponse' => 'un',
'mot' => 'peau',
'drag' => 'dra___',
'image' => 'img/drapeau.gif'
) ,
'chx_3' => array(
'reponse' => 'un',
'mot' => 'teau',
'drag' => 'pla___',
'image' => 'img/plateau.gif'
) ,
'chx_4' => array(
'reponse' => 'des',
'mot' => 'vau',
'drag' => 'tra___x',
'image' => 'img/panneau.gif'
) ,
'chx_5' => array(
'reponse' => 'de la',
'mot' => 'sau',
'drag' => '___ce',
'image' => 'img/sauce.gif'
) ,
'chx_6' => array(
'reponse' => 'un',
'mot' => 'seau',
'drag' => '____',
'image' => 'img/seau.gif'
) ,
'chx_7' => array(
'reponse' => 'du',
'mot' => 'cho',
'drag' => '___colat',
'image' => 'img/chocolat.gif'
),
'chx_8' => array(
'reponse' => 'une',
'mot' => 'to',
'drag' => '___mate',
'image' => 'img/tomate.gif'
) ,
'chx_9' => array(
'reponse' => 'des',
'mot' => 'chau',
'drag' => '___ssures',
'image' => 'img/chaussure.gif'
)
);
foreach($reponses as $cle => $reponse)
{
if (isset($_POST['correction']))
{
$clic = $_POST[$cle];
if (empty($clic) && empty($clic) != $reponse['mot'])
{
var_dump($clic);
$msg = '<p>veuillez remplir tous les champs</p>';
echo $msg;
}
else
if ($clic == $reponse['mot'])
{
echo '<p style="margin-left:4em;">' . $reponse['mot'] . '</p><p style="margin-left:5em;">'. $reponse['drag'] . '</p><br />';
}
else
if ($clic != $reponse['mot'])
{
$errors = array();
$errors[$cle] = htmlspecialchars($clic);
echo '<article class="content_img"><figure><img src="'. $reponse['image'] .'" alt="" width:"75" height="75" /></figure><p style="color:red;margin-left:4em;"><del>' . $errors[$cle] . '</del><p>'.$reponse['mot'].'</p><p style="text-align:right;margin-left:5em;">'. $reponse['drag'] . '</p></article>';
}
}
}
echo'<br />';
echo'<p style="display:inline-block;margin:2em 0 0 35%;padding:.5em;background:#54d0ce;font-size:1.2em;">Bonnes réponses :'.count($reponse['mot']).' - '.count($errors[$cle]).'/10</p>';
echo'<br /><br />';
?>[/php]
merci d'avance