Phpgraphlib:内部服务器错误

时间:2016-09-07 09:03:37

标签: internal-server-error phpgraphlib

我试图使用Phpgraphlib在我的网页上可视化图形。 我使用以下代码:

PHP脚本(graph.php):

<?php
include("phpgraphlib.php");
error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE);
$graph=new PHPGraphLib(550,350);

$link = mysql_connect('127.0.0.1', 'xxxx', 'xxxx') or die('Could not connect: ' . mysql_error());

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

$dataArray=array();

//get data from database
$sql="SELECT country, tot_reg FROM ntr_perf_no_net WHERE data = '2016-09-05'";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
    while ($row = mysql_fetch_assoc($result)) {
        $country=$row["country"];
        $reg=$row["tot_reg"];
        //add to data areray
        $dataArray[$country]=$reg;
    }
}

//configure graph
$graph->addData($dataArray);
$graph->setTitle("Tot registration per Country");
$graph->setGradient("lime", "green");
$graph->setBarOutlineColor("black");
$graph->createGraph();
?>

网页(graph.html):

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Graph</title>
</head>
<body>
<h3>This is where I want to display my graph</h3>
<img src="graph.php" />
</body>
</html>

这很简单,但我收到500内部服务器错误。 我知道PHP脚本是由服务器读取的(如果我在PHP脚本上添加了语义错误,我在apache日志中看到它),所以我无法理解错误。 SQL查询没问题,文件(Phpgraphlib.php,graph.html和graph.php)与777权限(文件和目录)位于同一目录中。

你能帮助我吗?

感谢 乔治

1 个答案:

答案 0 :(得分:0)

我忘了安装GD。安装后,它开始工作。