Mailer issue, PHP values do not change
- by Roland
I have a script that runs once every month and send out stats to clients, now the stats are displayed in normal text and in the shape of a Pie Graph, now if I run the script mannually from the command line all info on the graphs are correct, but when the cron job executes the script the values for the first client are displaying on the graphs of all clients. but the text is correct. I'm using domDocument to build the HTML and PHPMailer to send out the email with the Graphs embedded into the mail also use pChart to generate the Graph
My code that generates the PIE graph is below
include_once "pChart.1.26e/pChart/pData.class";
include_once "pChart.1.26e/pChart/pChart.class";
// Dataset definition
unset($DataSet);
$DataSet = new pData;
$DataSet->AddPoint(array($data['total_clicks'],$remaining),"Serie1");
if($remaining < 0){
$DataSet->AddPoint(array("Clicks delivered todate","Clicks remaining = 0"),"Serie2");
}else{
$DataSet->AddPoint(array("Clicks delivered todate","Clicks remaining"),"Serie2");
}
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$pie = new pChart(492,292);
$pie->drawBackground(255,255,254);
$pie->LineWidth = 1.1;
$pie->Values = 2;
// $pie->drawRoundedRectangle(5,5,375,195,5,230,230,230);
//$pie->drawRectangle(0,0,480,288,169,169,169);
$pie->drawRectangle(5,5,487,287,169,169,169);
$pie->loadColorPalette('pChart.1.26e/color/tones-3.txt',',');
// Draw the pie chart
$pie->setFontProperties("pChart.1.26e/Fonts/calibrib.ttf",18);
$pie->drawTitle(140,33,"Campaign Overview",0,0,0);
$pie->setFontProperties("pChart.1.26e/Fonts/calibrib.ttf",11);
$pie->drawTitle(343,125,"Total clicks : ".$total_clicks,0,0,0);
$pie->setFontProperties("pChart.1.26e/Fonts/calibri.ttf",10);
if($remaining < 0){
$pie->setFontProperties("pChart.1.26e/Fonts/calibrib.ttf",10);
$pie->drawTitle(260,250,"Campaign over-delivered by ".substr($remaining,1)." clicks",205,53,53);
$pie->setFontProperties("pChart.1.26e/Fonts/calibri.ttf",10);
}
$pie->drawPieLegend(328,140,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
$pie->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),170,150,130,PIE_VALUE,FALSE,50,30,0);
$pie->Render("generated/3dpie.png");
unset($pie);
unset($DataSet);
$mail->AddEmbeddedImage("/var/www/html/stats/generated/3dpie.png","5");
I just can't understand why this only happens when the cronjob runs?