Jump to content


Photo

JpGraph display weird things/symbols


  • Please log in to reply
3 replies to this topic

#1 wackyflik

wackyflik
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 07 October 2006 - 05:19 PM

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

<?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'");
}
?>


#2 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 07 October 2006 - 05:23 PM

i get

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



#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 07 October 2006 - 05:25 PM

This is your problem:
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'");

You cant have anything outputted before calling the header function.
You may do:
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>";

Orio.
Think you're smarty?

(Gone until 20 to November)

#4 wackyflik

wackyflik
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 07 October 2006 - 05:49 PM

nope...nothing change...but how come these codes work? i used this code when trying jpgraph which is taken from phpfreaks.

<?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'");
}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users