Bonjour.

Quand je veux enregistrer des modifications dans une tables j'ai un message qui m'annonce :'Undefinded variable langue ... line 142,
Undefined variable langue_sst ... line 158'

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function est_selectionne_langue($option) {
    if (!isset($_POST['langue'])) {
            return FALSE;
    }
    for ($i = 0, $c = count($_POST['langue']); $i < $c; $i++) {
        if ($_POST['langue'][$i] == $option) {
            return TRUE;
        }
    }
    return FALSE;
}
...
function est_selectionne_langue_sst($option) {
    if (!isset($_POST['langue_sst'])) {
            return FALSE;
    }
    for ($i = 0, $c = count($_POST['langue_sst']); $i < $c; $i++) {
        if ($_POST['langue_sst'][$i] == $option) {
            return TRUE;
        }
    }
    return FALSE;
}
...
if (isset($_POST['langue'])) {
    for ($i = 0, $c = count($_POST['langue']); $i < $c; $i++) {
	$langue .=  "" . $_POST['langue'][$i] . ",";   ***line 142***
    }
	$langue= substr($langue,0,strlen($langue)-1);
}
else {
	$langue="";
}
...
if (isset($_POST['langue_sst'])) {
    for ($i = 0, $c = count($_POST['langue_sst']); $i < $c; $i++) {
        $langue_sst .= "" . $_POST['langue_sst'][$i] . ",";  ***line 158***
    }
	$langue_sst= substr($langue_sst,0,strlen($langue_sst)-1);
}
...
	$sql = mysql_query("SELECT * FROM version_dvd wHERE id_titre = $choix AND id = $iddvd");
	if (mysql_num_rows($sql) > 0){
	   	$res = mysql_fetch_array($sql);
	   	$id = $res['id'];
	   	$langue = $res['langue'];
	   	$sous_titre = $res['sous_titre'];
	   	$langue_sst = $res['langue_sous_titre'];
	   	$public = $res['public'];

		$langue = explode(",",$langue);
		$langue_sst = explode(",",$langue_sst);
	}
			<p align="center">Langue<hr width='100px'>
    			<input type="checkbox" name="langue[]" value="Français" <?php if(est_selectionne_langue("Français")) { echo 'checked'; } else if(!empty($langue)){ if(in_array("Français",$langue)) { echo 'checked'; }} ?>/>Français<br/>
    			<input type="checkbox" name="langue[]" value="Anglais" <?php if(est_selectionne_langue("Anglais")) { echo 'checked'; } else if(!empty($langue)){ if(in_array("Anglais",$langue)) { echo 'checked'; }} ?>/>Anglais<br/>
    			<input type="checkbox" name="langue[]" value="Italien" <?php if(est_selectionne_langue("Italien")) { echo 'checked'; } else if(!empty($langue)){ if(in_array("Italien",$langue)) { echo 'checked'; }} ?>/>Italien<br/>
    			<input type="checkbox" name="langue[]" value="Allemand" <?php if(est_selectionne_langue("Allemand")) { echo 'checked'; } else if(!empty($langue)){ if(in_array("Allemand",$langue)) { echo 'checked'; }} ?>/>Allemand<br/>
    			<input type="checkbox" name="langue[]" value="Espagnol" <?php if(est_selectionne_langue("Espagnol")) { echo 'checked'; } else if(!empty($langue)){ if(in_array("Espagnol",$langue)) { echo 'checked'; }} ?>/>Espagnol<br/>
    			<input type="checkbox" name="langue[]" value="Portugais" <?php if(est_selectionne_langue("Portugais")) { echo 'checked'; } else if(!empty($langue)){ if(in_array("Portugais",$langue)) { echo 'checked'; }} ?>/>Portugais<br/>
			</p>
    			<input type="checkbox" name="langue_sst[]" value="Français" <?php if(est_selectionne_langue_sst("Français")) { echo 'checked'; } else if(!empty($langue_sst)){ if(in_array("Français",$langue_sst)) { echo 'checked'; }} ?>/>Français<br/>
    			<input type="checkbox" name="langue_sst[]" value="Anglais" <?php  if(est_selectionne_langue_sst("Anglais")) { echo 'checked'; } else if(!empty($langue_sst)){ if(in_array("Anglais",$langue_sst)) { echo 'checked'; }} ?>/>Anglais<br/>
    			<input type="checkbox" name="langue_sst[]" value="Italien" <?php  if(est_selectionne_langue_sst("Italien")) { echo 'checked'; } else if(!empty($langue_sst)){ if(in_array("Italien",$langue_sst)) { echo 'checked'; }} ?>/>Italien<br/>
    			<input type="checkbox" name="langue_sst[]" value="Allemand" <?php if(est_selectionne_langue_sst("Allemand")) { echo 'checked'; } else if(!empty($langue_sst)){ if(in_array("Allemand",$langue_sst)) { echo 'checked'; }} ?>/>Allemand<br/>
    			<input type="checkbox" name="langue_sst[]" value="Espagnol" <?php if(est_selectionne_langue_sst("Espagnol")) { echo 'checked'; } else if(!empty($langue_sst)){ if(in_array("Espagnol",$langue_sst)) { echo 'checked'; }} ?>/>Espagnol<br/>
    			<input type="checkbox" name="langue_sst[]" value="Portugais" <?php if(est_selectionne_langue_sst("Portugais")) { echo 'checked'; } else if(!empty($langue_sst)){ if(in_array("Portugais",$langue_sst)) { echo 'checked'; }} ?>/>Portugais<br/>
    			</p>
Sur cette page j'ai des boutons radio et des checkbox, ça marche pour les boutons radio mais pas pour les checkbox.

Merci de me dire ce qui ne va pas.