图像“http://localhost/chart/graph.php”无法显示,因为它包含错误在PHPGraphLib

图像“http://localhost/chart/graph.php”无法显示,因为它包含错误在PHPGraphLib

问题描述:

我不擅长PHP,可能是我的代码有问题?请!帮帮我。 这是我在表示上述图表代码:图像“http://localhost/chart/graph.php”无法显示,因为它包含错误在PHPGraphLib

功能show_graph($输入){

$dataArray1 = array(); 
$dataArray2 = array(); 

//get data from database 
$sql = sprintf("SELECT target_date, high, low FROM metal_price WHERE metal_kind ='%s' and metal_cd ='%s' and target_date BETWEEN '%s' and '%s' order by target_date", 
       $input["kind"], $input["cd"], 
       $input["date_from_y"]."/".$input["date_from_m"]."/".$input["date_from_d"], 
       $input["date_to_y"]."/".$input["date_to_m"]."/".$input["date_to_d"]); 

$result = mysql_query($sql) or die('Query failed: ' . mysql_error()); 
if ($result) { 
    while ($row = mysql_fetch_assoc($result)) { 
     $target_date=$row["target_date"]; 
     $high=$row["high"]; 
     $low=$row["low"]; 

     //add to data array 
     $dataArray1[$target_date]=$high; 
     $dataArray2[$target_date]=$low; 
    } 
} 

$graph->addData($dataArray1); 
$graph->addData($dataArray2); 
$graph->setTitle('Metal Price Chart'); 
$graph->setBars(false); 
$graph->setLine(true); 
$graph->setLineColor('blue', 'green'); 
$graph->setDataPoints(true); 
$graph->setDataPointColor('maroon'); 
$graph->setDataValues(true); 
$graph->setDataValueColor('maroon'); 
$graph->setLegend(true); 
$graph->setTitleLocation('center'); 
$graph->setTitleColor('blue'); 
$graph->setLegendOutlineColor('white'); 
$graph->setLegendTitle('High', 'Low'); 
$graph->setGoalLineColor('blue', 'green'); 
$graph->setXValuesHorizontal(true); 
$graph->createGraph(); 

}

每次我我的代码运行时我收到此错误:图片:“http: //localhost/chart/graph.php”无法显示,因为它包含错误

+0

你用什么库来实例化对象$ graph? –

不要忘记写 include('phpgraphlib.php'); $graph = new PHPGraphLib(500,350);