bonjours me revoila encore avec un probleme bidon :
voila j expose mon soucis c'est pas long
j ai realiser un mini script de vote jusque la tous va bien
sauf que au momment ou je demande d afficher le resultat de mes vote BANG
message d 'erreur qui me signale que dans mon scripte je fait une division par zero a la ligne 90 or je ne vois pas ou je fais cette fameuse division j espere que vous serez eclairer ma lanterne car j ai essayer plusieur solution mais rien n y fais voici le code
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml : lang="fr">
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-88591-1"/>
<title>Système de vote a l état pur </title>
<link href="votecss.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<fieldset id="field">
<Legend>Quel est votre s&eacute;rie favorite?</Legend>
<?php
$serie=array("sim"=>"The Simpson","gfi"=>"The Griffins","amd"=>"American Dad","tsb"=>"The Sponge Bob");
?>
<label>The Simpson</label><input type="radio" name="choix" value="sim"/><br/>
<label>The Griffins</label><input type="radio" name="choix" value="gfi"/><br/>
<label>American Dad</label><input type="radio" name="choix" value="amd"/><br/>
<label>The Sponge Bob</label><input type="radio" name="choix" value="tsb"/><br/>
<input type="submit"  value="voter"/>
<input type="submit" name="afficher" value="afficher"/>
</fieldset>
</form>
<?php
if(isset($_POST["choix"]))
{
$choix=$_POST["choix"];
echo"<h2>Le site de Julax vours remercie pour votre vote etant le suivant:".$serie[$choix]."</h2>";
if(file_exists("serie.txt"))
   {
    if($id_file=fopen("serie.txt","a"))
    {
	flock($id_file,2);
	fwrite($id_file,$choix."\n");
	flock($id_file,3);
    fclose($id_file);
	}
	else
	{
	echo"<h2>Fichier non accessible</h2>";
	}
}
 else
 {
   $id_file=fopen("serie.txt","w");
   fwrite($id_file,$choix."\n"); 
   fclose($id_file);  
 }
 }
 else
	{
	echo"<h2>Completer le formulaire ci contre et appuyer sur 'voter', Merci.</h2>";
	}
	$result=array("The Simpson"=>0,"The Griffins"=>0,"American Dad"=>0,"The Sponge Bob"=>0);
 
 
if(isset($_POST["afficher"]))
   {
    if($id_file=fopen("serie.txt","r"))
	  {
	    while($ligne=fread($id_file,6))
		{
		  switch($ligne)
		  {
		  case "sim\n":
		  $result["The Simpson"]++;
		  break;
		  case "gfi\n":
		  $result["The Griffins"]++;
		  break;
		  case "amd\n":
		  $result["American Dad"]++;
		  break;
		  case "tsb\n":
		  $result["The Sponge Bob"]++;
		  break;
		  }
	}
 
fclose($id_file);
}	
$total=($result["The Simpson"]+$result["The Griffins"]+ $result["American Dad"]+ $result["American Dad"])/100;
$tri=$result;
arsort ($tri);
echo"<div style=\"border-style:double\">";
echo"<h2>r&eacute;sultat du vote:</h2>";
foreach($tri as $nom=>$score)
{
$i="++";
echo"<h3>$i<sup>e</sup> : ",$nom," a $score voix soit",number_format($score/$total,2),"</h3>";
}
echo"</div>";
}        
?>
<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11"
alt="valid XHTML 1.1"height="35" width="92"/></a>
</body>
</html>