So I'm making a script that reads test results from a database and displays the results, then uses PostGraph ( http://www.qualityunit.com/postgraph/ ) to show the results as a graph, however when I call the function I get the following error:
this obviously means that headers are being sent twice, then the rest of the crap is the actual image.
if I use the external example file it outputs the image perfect, however I have no way to send the array of data to it.
If I remove the header line from the PHP it just outputs the image but the browser wont display it as such, is there a way to do this?
This is the printImage function which isn't working properly.
This is what is in my code at the moment, after everything else
Any ideas?
Hamish
Code:
Warning: Cannot modify header information - headers already sent by (output started at
/Applications/xampp/xamppfiles/htdocs/calproject/header.php:8) in
/Applications/xampp/xamppfiles/htdocs/calproject/postgraph/postgraph.class.php
on line 291
‰PNG ���
IHDR��&��J���Û>‰É���PLTEÿÿÿHkHkçç窪ª������ÿÿÿá˼��"IDATxœí[’›8@™ýO&+H²‚W±~X«Øÿb 0 {±1„„ÎéNu7ÁF>¾º€VU��”…iÛöì2¤†iì7ÌÁ‰¤wbëiqÓãò‰i¬—ŠÄÒã*ÎCFK%z‚ N$ÎùdAœw��������2¦m*svÃ<¾š»<Œ!PO©[Þï%åÄ6Û·ñÔ®i")'öóÙN™«’´“¾îÄîóªo ;9iž×=e'çÌó²G
çØ$æ¾¥å¤mSèMÊÉNpâÀ‰'’щÑ?§<šïåÿ±ÛÎvÒ6êòE;iõ³Ûq‚dzîèk´ídeéÓ¢¬P¸òÉN$_C6!ÇNàDòõ¬7Ôò‰$Ïsq}뮞œÌ¯ÙL?ý-Y'Ý-ä ÙçýN5ϱm{M¢Oã$ä
ÙÉÉ,Ÿ¸UšŠw⋇º±ðS'!Ç›ON–ù$í8éîœTË»âÔ„e}Ž$N×l¶0ésqXN»Žõ¦´¥çÄ4±ïk/KâäæIJЉwÍÇÉ}~ÙµÕ‰¿íO€¢—O–ÓAÓt¢.Ÿtûrl\'yôeÄt²¼/ÆÉ)9Ö#A'Ù´QÇuB>Ñï‹qò‚NÔ—…œxàD‚I¦NLÈÏ"ËÔI;^Õâä&fßV´S)ý;aú¼²qÒ¯0\_F6Ncp2 £Úç•“Å„°}^Ù81ñÚ³q²BáN¢µ=âD’‰“¨}£8‘dâ$j_F6NÈ'œ‹%ÏëØx}£ù8!Ç>yÖU
NpÒCÝ‘c%œ‹%Ó ·fb¶N¨; œwD”M99±ËÂ¥®Ùp"œõ9»8‘\ÉÉAU' Wrr8‘àD‚
N$8‘\ÂÉoeÇo€
N$8‘àD‚Éš“Su$'ÍqqboWëÙ=k®NƱm8q:櫨dëÄõÒçu¿NœÖ¿ãV|¼DœØçeWdÂÉëä u'¯ñ'‘œà'œHp"Á‰$°*´8Á‰N$8‘àD‚ NúÛßn¶(Núf’ùp!œôÃìæÃTq2ÄȬM
'ÖÆ²ñRNöµ³u×Îxº“ÅÂÑßsrT{ìÙNê=DÏU9ÛÉ®A³«ýÅÇôyîdÏxó«ÇÉŽ0¹º“]szöçX•ïÒúÙNv±ÿ\ÜÝ–i}si³u2ð.Nòtò¦>}Óɇ]ãi8©:y<÷‡]ãi8 'ݽ¾ÏÓ:N$‰9QwÄÉš“úÍD‰NÞœêäí}CæNfWZ[Ô‹›î½/5a'÷éMÇIéN´q"wÜïd™c¿Uˆ4ìȱK¾Uˆ4ÌØáäK{îŸJ!¾±£Û&|·£äN6;y±þN±NšõöØR¼j·/Û‰ëôžæ—²í·Ýöß‘;þÒv<ü(êŽMoâDù?m[õïÑ;Æ9Šº£¶*‰ʘc£"'ã¹8J!2qòâyJw��p ÚâÚrWFÛQÙf´åµoÞQ/Žvð¦’K—ý9_¡–V{*ÚJiúƒôRm=жcÛ¯íîGêkõuï^¢wcL4êÛ¯=V{B*¨ªe]½t²'úÛôŠ*¥Õ6êkÊiïªúúµÇª¿éäÓº³5$VJ+7m®xÛ¢f³“ÃDõíÙïè½=Ç>Š(v}¼Yò¶YY!�à,óæð—ºøv9LNìoð"Jtbšþ?.ÜW3^ñØåêíwëbE½º*£“Ç/Ö‰»5kû¿çu§U/Æ®Êpåh—BbQiF'E]`¶CT˜ÑÉ Å“‚êŽýá×¶wÒWw¦k˜¡ ¹-éóì|#�����ÀÇü|Ü£ÈiW"Ã����IEND®B`‚
this obviously means that headers are being sent twice, then the rest of the crap is the actual image.
if I use the external example file it outputs the image perfect, however I have no way to send the array of data to it.
If I remove the header line from the PHP it just outputs the image but the browser wont display it as such, is there a way to do this?
This is the printImage function which isn't working properly.
Code:
/**
* draw graph to the output
*
* @param null
* @returns nothing
*/
function printImage()
{
header("Content-type: image/jpeg");
ImagePNG($this->img);
}
This is what is in my code at the moment, after everything else
Code:
include('postgraph/postgraph.class.php');
$data = array(1 => 0, 1.2, 2.5, 4.8, 16, 20, 22, 17, 7, 2, 1, 0);
$graph = new PostGraph(550,330);
$graph->setGraphTitles('My Graph', 'x axis title', 'y axis title');
$graph->setYNumberFormat('integer');
$graph->setYTicks(10);
$graph->setData($data);
$graph->setXTextOrientation('horizontal');
$graph->drawImage();
$graph->printImage();
Any ideas?
Hamish