Foros del Web » Programando para Internet » PHP »

error en jpgraph

Estas en el tema de error en jpgraph en el foro de PHP en Foros del Web. Me sale el siguiente error en jpgraph: "JpGraph Error: HTTP headers have already been sent. Caused by output from file clagunas.php at line 12. Explanation: ...
  #1 (permalink)  
Antiguo 27/02/2011, 05:48
 
Fecha de Ingreso: febrero-2011
Mensajes: 2
Antigüedad: 13 años, 2 meses
Puntos: 0
error en jpgraph

Me sale el siguiente error en jpgraph:


"JpGraph Error: HTTP headers have already been sent.
Caused by output from file clagunas.php at line 12.
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).
Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.

For example it is a common mistake to leave a blank line before the opening "<?php"."



Este es mi codigo

<?php
include ('Clases.php');
$conexion = conectar();
$fecha = $_POST['txtFecha'];
$formateo = str_replace('/','-',$fecha);
$fecha = date('Y-m-d', strtotime($fecha));
$fecha2 = $_POST['txtFecha2'];
$formateo = str_replace('/','-',$fecha2);
$fecha2 = date('Y-m-d', strtotime($fecha2));
$sql=mysql_query("SELECT * FROM generales where fecha_gen between '$fecha' and '$fecha2' ORDER BY fecha_gen Asc");
$ydata = array();
while($bus = mysql_fetch_array($sql)){
array_push($ydata,$bus[valor_gen]);
}
$sql2=mysql_query("SELECT * FROM generales2 where fecha_gendos between '$fecha' and '$fecha2'ORDER BY fecha_gendos Asc");
$ydata2 = array();
while($bus = mysql_fetch_array($sql2)){
array_push($ydata2,$bus[valor_gendos]);
}
$sql3=mysql_query("SELECT * FROM generales where fecha_gen between '$fecha' and '$fecha2'ORDER BY fecha_gen Asc");
$xdata = array();
while($bus = mysql_fetch_array($sql3)){
array_push($xdata,$bus[fecha_gen]);
}
include("jpgraph.php");
include("jpgraph_line.php");
$graph = new Graph(1000,450,"auto");
$graph->SetScale("textlin");
$graph->title->Set('Piso de Ruido generales');
$graph->xaxis->title->Set('Fecha');
$graph->yaxis->title->Set('Nivel en dB');
$graph->ygrid->SetFill(true,'#[email protected]','#[email protected]');
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetLabelAngle(90);
$lineplot = new LinePlot($ydata);
$lineplot->SetColor("red");
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetFillColor("red");
$lineplot->mark->SetWidth(2);
$lineplot->SetLegend("Piso de Ruido");
$lineplot2 = new LinePlot($ydata2);
$lineplot2->SetColor("green");
$lineplot2->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot2->mark->SetFillColor("green");
$lineplot2->mark->SetWidth(2);
$lineplot2->SetLegend("Diferencia");
$graph->Add($lineplot);
$graph->Add($lineplot2);
$graph->Stroke();
mysql_close($conexion);
?>


Gracias
  #2 (permalink)  
Antiguo 27/02/2011, 10:24
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: error en jpgraph

Con sencillamente traducir el error que colocaste arriba obtienes la respuesta, dice que hay una salida de datos por lo que no puede enviar las cabeceras para enviar el grafico, que debes de hacer?? revisar que no halla salida, entiendase como salida codigo html, un espacio antes de cerrar el php "?>" (esto me dio un dolor de cabeza descubrirlo una vez que tube ese error ), algun echo en algunos de los archivos que incluyes, cual de todas es?? te toca revisarlo en tus archivos, saludos
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #3 (permalink)  
Antiguo 28/02/2011, 00:58
 
Fecha de Ingreso: febrero-2011
Mensajes: 2
Antigüedad: 13 años, 2 meses
Puntos: 0
Respuesta: error en jpgraph

Ve lo que pasa es que ese mismo codigo lo tengo en mi pc y funciona sin problemas, pero al pasarlo a un servidor y me sale ese error no he modificado nada y no entiendo lo que tu me dices, bueno si lo entiendo pero no encuentro la logica, un espacio donde en los includes, si lo unico que mando llamar es un archivo para que se conecte a la base de datos eso es todo, si ves con ese mismo archivo mando llamar los datos de la base de datos, pero le seguire intentando

Etiquetas: jpgraph
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:56.