gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 03:41:12 25 4
gpt4 key购买 nike

我的 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”无法显示,因为它包含错误

最佳答案

别忘了写include('php graphlib.php');
$graph = new PHPGraphLib(500,350);
$dataArray1 = array();
$dataArray2 = array();

关于php - 图片“http ://localhost/chart/graph. php”无法显示,因为它在 PHPGraphLib 中包含错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13599534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com