我的 PHP 不太好,我的代码可能有什么问题?请!帮助。这是我显示图表的代码:
功能显示图($输入){
$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”,因为它包含错误