2016-09-07 40 views
0

我试图使用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权限(文件和目录)的同一目录中。

你能帮我吗?

感谢 乔治

回答

0

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