cannot display the graph...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
teckyan888
Forum Commoner
Posts: 40
Joined: Tue May 11, 2004 10:46 am

cannot display the graph...

Post by teckyan888 »

Code: Select all

<?php
<?php 
include ("C:\Program Files\Apache Group\Apache2\htdocs\jpgraph-1.12.2\src\jpgraph.php");    
include ("C:\Program Files\Apache Group\Apache2\htdocs\jpgraph-1.12.2\src\jpgraph_bar.php"); 

$db = mysql_connect("localhost", "root","") or die(mysql_error()); 
echo $db;
mysql_select_db("cb359",$db) or die(mysql_error()); 

$sql = mysql_query("SELECT * FROM students") or die(mysql_error()); 
while($row = mysql_fetch_array($sql)) 
{ 
$data[] = $row[1]; 
$leg[] = $row[0]; 
} 

$graph = new Graph(250,150,"auto"); 
$graph->SetScale("textint"); 
$graph->img->SetMargin(50,30,50,50); 
$graph->AdjBackgroundImage(0.4,0.7,-1); //setting BG type 
$graph->SetBackgroundImage("linux_pez.png",BGIMG_FILLFRAME); //adding image 
$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->Stroke(); 
?> 


?>
There is the code i try to test...But,it doesn't output any graph...and it doesn't show any error...It just blank only...Anyone who know what the problem???thanks...
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Theres 2

Code: Select all

<?php<?php ?> ?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Dale wrote:Theres 2

Code: Select all

<?php<?php ?> ?>
Most likely because his code had them originally in it plus the bbtags ones too....
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

im not familiar w/ jpgraph, but is that code supposed to output anything?
it looks like the last line strokes the image, which i really doubt is how you tell jpgraph to output the image to the browser.

you prob still need to output the image.

i think i tried jpgraph a long time ago, and remember they had a directory w/ lots of sample php files which would output sample graphs. might wanna look at them.
teckyan888
Forum Commoner
Posts: 40
Joined: Tue May 11, 2004 10:46 am

Post by teckyan888 »

oh...That is not the problem of <?php<?php ?> ?> ...Coz i post the code,and insert again the <?php ?> only...
Ya..I have try to see the example...But it doesn't show any output also...Is it got any problem in my installation so it cannot detach the graph i mentioned in the code???
Post Reply