Bonjour, j'essaye de crée une page web en php avec un graphique d'où les données sont issues d'une base de données mais j'ai constament des erreurs des fois sa précise la ligne où sont les erreurs mais d'autre fois j'ai un petit carré blanc qui s'affiche !

Voici la page php :

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
<!DOCTYPE html>
<html lang="fr">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tagsThe above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">
 
    <title>Système Domotique Modulaire</title>
 
    <!-- Bootstrap core CSS -->
    <link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
 
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
 
    <!-- Custom styles for this template -->
    <link href="cover.css" rel="stylesheet">
 
    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="../../assets/js/ie-emulation-modes-warning.js"></script>
 
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
 
  <body>
 
    <div class="site-wrapper">
 
      <div class="site-wrapper-inner">
 
        <div class="cover-container">
 
          <div class="masthead clearfix">
            <div class="inner">
              <h3 class="masthead-brand">Système Domotique Modulaire</h3>
              <nav>
                <ul class="nav masthead-nav">
                  <li><a href="/bootstrap-3.3.7/docs/examples/cover/index.html">Accueil</a></li>
                  <li><a href="http://10.10.13.250">Consommation</a></li>
                  <li class="active"><a href="#">Historique</a></li>
                </ul>
              </nav>
            </div>
          </div>
 
          <div class="inner cover">
			<?php
			include("histo2.php");
			?>
          </div>
 
          <div class="mastfoot">
            <div class="inner">
              <p>Cover template for <a href="http://getbootstrap.com">Bootstrap</a>, by <a href="http://10.10.13.214/snir/">Sn2</a>.</p>
            </div>
          </div>
 
        </div>
 
      </div>
 
    </div>
 
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
    <script src="../../dist/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
  </body>
</html>

index3.php

et le fichier php :

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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
 
require_once ('\jpgraph-4.0.2\src\jpgraph.php');
require_once ('\jpgraph-4.0.2\src\jpgraph_bar.php');
 
//phpinfo();
 
$indexHC = array();
$tableauHC = array();
$indexHP = array();
$tableauHP = array();
$datation = array();
$axeX = array();
 
// *************************************************
// Extraction des données dans la base de données
// *************************************************
 
// Connexion au serveur de base de données
$link = mysql_connect("127.0.0.1:3306","root","");
if (!$link) 
{
	die('Connexion impossible : ' . mysql_error());
}
//echo "Connexion OK <br>";
 
// Sélection de la base de données
$db_selected = mysql_select_db('sgbd_sdm',$link);
if (!$db_selected) 
{
	die ('Impossible de sélectionner la base de données : ' . mysql_error());
}
//echo "Base ouverte <br>";
 
$date_param = isset($_GET['date']);
$date1 = $date_param." 00:00:00";
//$date2 = $date." 23:59:59";
$dateLendemain=date_create($date_param);
//$dateLendemain->add(date_interval_create_from_date_string("1 day"));
$dateLendemain->modify('+1 day');
$date2 = date_format($dateLendemain,"Y-m-d");
// Dépassement de 30 minutes pour avoir 25 valeurs et 24 tranches horaires
$date2 .= " 00:30:00";
//echo $date2."<br />";
 
$sqlHC = "SELECT `valeurs`,`datation` FROM `indexhc` WHERE `datation` > '".$date1."' AND datation < '".$date2."'";
$sqlHP = "SELECT `valeurs`,`datation` FROM `indexhp` WHERE `datation` > '".$date1."' AND datation < '".$date2."'";
//echo $sqlHC."<br />";
$resultHC = mysql_query($sqlHC) or die('Erreur SQL<br />');
while ($row = mysql_fetch_array($resultHC,  MYSQL_ASSOC)) 
{
	$indexHC[] = $row['valeurs'];
	$datation[] = $row['datation'];
}
 
// Ajouté le 05/06/2014 : Valeurs en heures pleines
$resultHP = mysql_query($sqlHP) or die('Erreur SQL<br />');
while ($row = mysql_fetch_array($resultHP,  MYSQL_ASSOC)) 
{
	$indexHP[] = $row['valeurs'];
    $datation[] = $row['datation'];
 
}
 
// Ajouté le 26/05/2014 : Recherche si valeurs manquantes
for ($i=0;$i<24;$i++)
{
	$tableauHC[$i] = 0;
	$tableauHP[$i] = 0;
	$axeX[$i] = strval($i)."-".strval($i+1);
	//echo $i."<br />";
}
 
$nbValeurs = count($indexHC);	// Ou HP peu importe
//$nbValeurs = count($indexHP);
 
//echo $nbValeurs."<br />";
 
// Si il manque des valeurs alors on regarde ce qui est disponible
if ($nbValeurs < 25)
{
	$premiereValeur = intval(substr($datation[0],11,2));
	//echo $premiereValeur."<br />";
	$derniereValeur = intval(substr($datation[$nbValeurs-1],11,2));
	//echo $derniereValeur."<br />";
}
else $premiereValeur = 0;
 
if ($nbValeurs > 1) // Il faut au moins 2 valeurs pour calculer un delta
{
	for ($i=0;$i<$nbValeurs-1;$i++)
	{
		$tableauHC[$premiereValeur] = $indexHC[$i+1]-$indexHC[$i];
		$tableauHP[$premiereValeur] = $indexHP[$i+1]-$indexHP[$i];
		$premiereValeur++;
	}
}
 
//die('FIN<br />');	// Pour déboguer
 
// *********************
// Création du graphique
// *********************
 
 
// Construction du conteneur
// Spécification largeur et hauteur
$graph = new Graph(1780,500);
 
// Réprésentation linéaire
$graph->SetScale("textlin");
 
// Ajouter une ombre au conteneur
$graph->SetShadow();
 
// Fixer les marges
$graph->img->SetMargin(40,30,25,40);
 
// Création du graphique histogramme
$bplotHC = new BarPlot($tableauHC);
$bplotHP = new BarPlot($tableauHP);
 
// Spécification des couleurs des barres
$bplotHC->SetFillColor(array('blue'));
$bplotHP->SetFillColor(array('green'));
 
// Une ombre pour chaque barre
$bplotHC->SetShadow();
$bplotHP->SetShadow();
 
// Afficher les valeurs pour chaque barre
$bplotHC->value->Show();
$bplotHP->value->Show();
 
// Fixer l'aspect de la police
$bplotHC->value->SetFont(FF_ARIAL,FS_NORMAL,9);
$bplotHP->value->SetFont(FF_ARIAL,FS_NORMAL,9);
 
// Légendes
$bplotHC->SetLegend('Heures creuses');
$bplotHP->SetLegend('Heures pleines');
 
// Ajouter les barres au conteneur
$gbplot = new GroupBarPlot(array($bplotHC,$bplotHP));
$graph->Add($gbplot);
 
// Le titre
$titre = "Consommation en Wh - ";
$titre .= date_format(date_create($date_param),"d-m-Y");
$graph->title->Set($titre);
$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
// Titre pour l'axe horizontal(axe x) et vertical (axe y)
$graph->xaxis->title->Set("heures");
//$graph->yaxis->title->Set("Wh");
 
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
 
// Légende pour l'axe horizontal
$graph->xaxis->SetTickLabels($axeX);
 
// Afficher le graphique
$graph->Stroke();
 
?>
histo2.php