Jump to content

Archived

This topic is now archived and is closed to further replies.

wackyflik

JpGraph display weird things/symbols

Recommended Posts

i've got some weird output like symbols when run these codes. what happened actually??

[code]
<?php
session_start();
if(isset($_SESSION['user'])) {

$dateId = $_GET['id'];

function generateGraph($year, $month){
include('../config_default.php');
include('../jpgraph/src/jpgraph.php'); 
include('../jpgraph/src/jpgraph_bar.php');

$sql = "SELECT f.facultyInitial,
        COUNT(*) AS Total
FROM attendance att
INNER JOIN academic a
ON att.academicNo = a.academicNo
INNER JOIN program p
ON a.programId = p.programId
INNER JOIN faculty f
ON p.facultyId = f.facultyId
WHERE MONTH(att.attendanceDate) = $month
AND YEAR(att.attendanceDate) = $year
GROUP BY f.facultyInitial
ORDER BY f.facultyInitial";
$query = mysql_query($sql);
$row = mysql_num_rows($query);
if($row <> 0){
while($result = mysql_fetch_array($query)){
$data[] = $result['total'];
$leg[] = $result['facultyInitial'];
}

$graph = new Graph(500,400,"auto");

$graph->SetScale("textint");
$graph->img->SetMargin(50,30,50,50);
$graph->AdjBackgroundImage(0.4,0.7,-1);
$graph->SetShadow();

$graph->xaxis->SetTickLabels($leg);//

$bplot = new BarPlot($data);//
$bplot->SetFillColor("lightgreen"); // Fill color
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
$bplot->value->SetColor("black","navy");

$graph->Add($bplot);
$graph->title->Set("Numbers of Students");
$graph->xaxis->title->Set("Faculty");
$graph->yaxis->title->Set("No. of Students");
$graph->Stroke();
}
else{
echo "<center><font face=\"Georgia, Times New Roman, Times, serif\" color=\"#000000\">Sorry, no record is found.</font></center>";
}
}

function splitDate($dateId){
$tempDate = explode('-', $dateId);

/*
* add 0 in front of the month if
* month parameter is between 1 and 9
*/
if($tempDate[1] >= 1 && $tempDate[1] <= 9)
$tempDate[1] = "0" . $tempDate[1];
else
$tempDate[1] = $tempDate[1];

generateGraph($tempDate[0], $tempDate[1]);
}

if(isset($dateId)){
splitDate($dateId);
}
}
else{
echo "<br><br><center><font face=\"Georgia, Times New Roman, Times, serif\">Warning: You are trying accessing restricted page.</font></center>";
header("Refresh:2, url='../auth/login_form.html'");
}
?>
[/code]

Share this post


Link to post
Share on other sites
i get

[quote]
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\tests\5\a.php:80) in C:\wamp\www\tests\5\a.php on line 81
[/quote]

Share this post


Link to post
Share on other sites
This is your problem:
[code]echo "<br><br><center><font face=\"Georgia, Times New Roman, Times, serif\">Warning: You are trying accessing restricted page.</font></center>";
header("Refresh:2, url='../auth/login_form.html'");[/code]

You cant have anything outputted before calling the header function.
You may do:
[code]header("Refresh:5, url='../auth/login_form.html'");
echo "<br><br><center><font face=\"Georgia, Times New Roman, Times, serif\">Warning: You are trying accessing restricted page.</font></center>";[/code]

Orio.

Share this post


Link to post
Share on other sites
nope...nothing change...but how come these codes work? i used this code when trying jpgraph which is taken from phpfreaks.

[code]
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
session_start();
if(isset($_SESSION['user'])) {
include('../config_default.php');
include('../jpgraph/src/jpgraph.php'); 
include('../jpgraph/src/jpgraph_bar.php');
$year = 2006;
$sql = "SELECT COUNT(*) total, f.facultyInitial
FROM attendance att
INNER JOIN academic a
ON att.academicNo = a.academicNo
INNER JOIN program p
ON a.programId = p.programId
INNER JOIN faculty f
ON p.facultyId = f.facultyId
WHERE YEAR(att.attendanceDate) = $year
GROUP BY (f.facultyId)
ORDER BY f.facultyInitial";
$query = mysql_query($sql);
$row = mysql_num_rows($query);
if($row <> 0){
while($result = mysql_fetch_array($query)){
$data[] = $result['total'];
$leg[] = $result['facultyInitial'];
}

$graph = new Graph(500,400,"auto");

$graph->SetScale("textint");
$graph->img->SetMargin(50,30,50,50);
$graph->AdjBackgroundImage(0.4,0.7,-1);
$graph->SetShadow();

$graph->xaxis->SetTickLabels($leg);//

$bplot = new BarPlot($data);//
$bplot->SetFillColor("lightgreen"); // Fill color
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
$bplot->value->SetColor("black","navy");

$graph->Add($bplot);
$graph->title->Set("Numbers of Students");
$graph->xaxis->title->Set("Faculty");
$graph->yaxis->title->Set("No. of Students");
$graph->Stroke();
}
else{
echo "Database is empty";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<br />
JpGraph 1
</body>
</html>
<?php
}
else{
echo "<br><br><center><font face=\"Georgia, Times New Roman, Times, serif\">Warning: You are trying accessing restricted page.</font></center>";
header("Refresh:2, url='../auth/login_form.html'");
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.