IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[JpGraph] message d'erreur: HTTP headers have already been sent


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    219
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 219
    Points : 61
    Points
    61
    Par défaut [JpGraph] message d'erreur: HTTP headers have already been sent
    Bonjour,
    J'ai le messsage suivant qui s'affiche lorsque j'execute ma page:
    JpGraph Error: HTTP headers have already been sent.
    Caused by output from file jpgraph.php at line 8.
    Comment faire??

    Voici mon 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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    <?include("inc/conf.inc");?>
    <?
    $ww = 28;
    $tvar = array('NB','nb','NJ','nj','PB','pb','PJ','pj');
    ?>
    <table width=* border=1 cellspacing=0 cellpadding=5>
    <tr align=center valign=center>
      <td><strong>Semaine <?=$ww;?></td>
    <?
    $sql = "SELECT * FROM regions ORDER BY regions_nom;";
    $result = mysql_query($sql);
    $cptreg = 0;
    while ($rs = mysql_fetch_array($result)) {
      $cptreg++;
      $regions_nom = $rs['regions_nom'];
      $treg[$cptreg] = $rs['regions_id'];
      $tzone[$cptreg] = 0;
    ?>
      <td><strong><?=$regions_nom;?></strong></td>
    <?
    }
    ?>
      <td><strong>Total</strong></td>
    </tr>
    <? for ($n=1;$n<=4;$n++) { ?>
    <tr align=center>
      <td><strong><?=$tvar[($n-1)*2];?></strong></td>
    <?
    $result = mysql_query($sql);
    $m = 0;
    $totalvar = 0;
    while ($rs = mysql_fetch_array($result)) {
      $m++;
      $tmp = "prev_".$tvar[($n*2)-1]."_ton";
      $o = $treg[$m];
      $sql2 = "SELECT SUM($tmp) AS nbre FROM prev, operateurs WHERE prev.operateurs_id = operateurs.operateurs_id AND regions_id = $o AND prev_ss = $ww;";
      $result2 = mysql_query($sql2);
      $rs2 = mysql_fetch_array($result2);
      $nbre = $rs2['nbre']*1;
      $tableau[$n][$m]=$nbre;
      $tzone[$m] = $tzone[$m] + $nbre;
      $totalvar = $totalvar + $nbre;
    $x = array($nbre);
      echo("<td>$nbre</td>");
    ?>
    <? } ?>
      <td><strong><?=$totalvar;?></strong></td>
    </tr>
    <? } ?>
     
    <tr align=center>
      <td><strong>TOTAL</strong></td>
    <?
    $total = 0;
    for ($k=1;$k<=$cptreg;$k++) {
      $total = $total+$tzone[$k];
    ?>
      <td><strong><?=$tzone[$k];?></strong></td>
    <? } ?>
      <td><strong><?=$total;?></strong></td>
    </tr>
    </table>
     
    <?php
    include ("jpgraph-1.21b/src/jpgraph.php");
    include ("jpgraph-1.21b/src/jpgraph_bar.php");
    setlocale (LC_ALL, 'et_EE.ISO-8859-1');
     
    $data1y=array(1237,710,470);
    $data2y=array(2060,1031,585);
    $data3y=array(1186,514,440);
    $data4y=array(622,877,475);
     
    // Create the graph. These two calls are always required
    $graph = new Graph(500,400,"auto");    
    $graph->SetScale("textlin");
     
    $graph->SetShadow();
    $graph->img->SetMargin(60,50,40,60);
     
     
    // Create the bar plots
    $b1plot = new BarPlot($data1y);
    $b1plot->SetPattern(BAND_RDIAG,"white");
    $b1plot->SetLegend("NB");
    $b1plot->SetFillColor("orange");
    $b2plot = new BarPlot($data2y);
    $b2plot->SetFillColor("orange");
    $b2plot->SetLegend("NJ");
    $b3plot = new BarPlot($data3y);
    $b3plot->SetFillGradient('white','green',GRAD_CENTER);
    $b3plot->SetLegend("PB");
    $b4plot = new BarPlot($data4y);
    $b4plot->SetFillColor("green");
    $b4plot->SetLegend("PJ");
     
    $graph->SetBackgroundGradient('#9999FF','white',GRAD_HOR,BGRAD_MARGIN);
     
    $graph->legend->Pos(0.03,0.5,"right","center");
    $graph->legend->SetFont(FF_FONT1,FS_BOLD);
     
    // Create the grouped bar plot
    $gbplot = new AccBarPlot(array($b1plot,$b2plot,$b3plot,$b4plot));
    $lbl = array("Roussillon","Gard-Crau","Vallée Rhône");
    $graph->xaxis->SetTickLabels($lbl);
     
    // ...and add it to the graPH
    $graph->Add($gbplot);
     
    $graph->title->Set("Prévisions apports S28 par région
    ");
    $graph->xaxis->title->Set("Régions");
    $graph->yaxis->title->Set("Tonnes");
     
    $graph->title->SetFont(FF_FONT1,FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
     
    // Display the graph
    $graph->Stroke();
    ?>

  2. #2
    Membre confirmé
    Profil pro
    Développeur Web
    Inscrit en
    Avril 2006
    Messages
    430
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Avril 2006
    Messages : 430
    Points : 557
    Points
    557
    Par défaut
    la raison est que jpgraph fait de l'ouput de headers pour déclarer la sortie du graphique en tant qu'image... Tu ne peux donc mettre la sortie du graphique dans le flux normal de ta page. Tu dois pas contre faire un script php séparé, qui s'occupe de faire le graphique (et uniquement le graphique), et inclure l'appel vers ce script, via un tag <img> dans ta page principale.

    En admettant que tu fasses un script "graph.php" (qui ne contient que le code jpgraph), tu aurais donc dans ton html
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
      ...
      <td><strong><?=$total;?></strong></td>
    </tr>
    </table>
    <img src="graph.php" />
    et dans graph.php, tout le reste.
    Merci à Microsoft pour avoir transformé un métier relativement terne et basé sur une approche bêtement technique et rigoureuse des faits, en challenge quotidien, nécessitant une remise en question permanente à l'échelle du quart d'heure

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    219
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 219
    Points : 61
    Points
    61
    Par défaut
    mon problème c'est que si je fais ça ça ne marche pas car j'utilise un tableau que j'ai créer dans une boucle et donc après il me met que une variable non définie.

  4. #4
    Membre confirmé
    Profil pro
    Développeur Web
    Inscrit en
    Avril 2006
    Messages
    430
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Avril 2006
    Messages : 430
    Points : 557
    Points
    557
    Par défaut
    et bien rajoute dans le script qui génère le graphique tout le code nécessaire à jpgraph pour qu'il puisse te faire ca sans erreurs...
    Merci à Microsoft pour avoir transformé un métier relativement terne et basé sur une approche bêtement technique et rigoureuse des faits, en challenge quotidien, nécessitant une remise en question permanente à l'échelle du quart d'heure

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    219
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 219
    Points : 61
    Points
    61
    Par défaut
    Non mais j'utilise un tableau qui est dans l'autre fichier mais je sais pas comment faire pour aller prendre les valeurs de ce tableau dans l'autre fichier. Sinon j'ai réussi en créant une image mais je ne veux pas générer d'image.

Discussions similaires

  1. message d'erreur <The module has not been deployed>
    Par alamako dans le forum Logging
    Réponses: 4
    Dernier message: 08/09/2010, 09h02
  2. Réponses: 5
    Dernier message: 02/07/2010, 18h53
  3. N° message CMS025 " erreur HTTP sur SAP"
    Par azizb dans le forum SAP
    Réponses: 0
    Dernier message: 06/10/2008, 13h32
  4. [JpGraph] Error: HTTP headers have already been sent.
    Par haffouff dans le forum Bibliothèques et frameworks
    Réponses: 8
    Dernier message: 09/05/2006, 16h17
  5. Message d'erreur "https is not supported"
    Par nono08 dans le forum Web
    Réponses: 5
    Dernier message: 04/04/2006, 14h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo