Page 1 of 1

HELPPPPP........

Posted: Wed Nov 10, 2004 1:41 pm
by teckyan888
i cannot get any output from the below statement....
It display "No database selected".....
Anyone who know what the problem of these statement???

Code: Select all

<?php
include ("c:/jpgraph-1.12.2/src/jpgraph.php"); 
include ("c:/jpgraph-1.12.2/src/jpgraph_bar.php"); 

$sql = mysql_query("select 1998,sum(noofpassenger),sum(noofcompany) from info where departuredate like '1998%'") or die(mysql_error()); 
echo $sql;

while($row = mysql_fetch_array($sql)) 
{ 
$data1y[] = $row[1]; 
$data2y[] = $row[2]; 
$leg[] = $row[0]; 
} 

// Create the graph. These two calls are always required
$graph = new Graph(310,200,"auto"); 
$graph->SetScale("textlin");

$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);

// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");

// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot,$b2plot));

// ...and add it to the graPH
$graph->Add($gbplot);

$graph->title->Set("Example 21");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->xaxis->SetTickLabels($leg);

$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

// Display the graph
$graph->Stroke();
?>

Posted: Wed Nov 10, 2004 2:15 pm
by josh
You probably did not select a database then...

Code: Select all

mysql_select_db('my_database') or die('Could not select database');