【问题标题】:the image"http://localhost/chart/graph.php" cannot be displayed because it contains errors In PHPGraphLib图像“http://localhost/chart/graph.php”无法显示,因为它在 PHPGraphLib 中包含错误
【发布时间】:2012-11-28 07:00:45
【问题描述】:

我的 PHP 不太好,我的代码可能有什么问题?请!帮助。 这是我显示图表的代码:

函数 show_graph($input) {

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

【问题讨论】:

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

标签: php mysql printf phpgraphlib


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多