2016-09-07 3 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 스크립트에 의미 론적 오류가있는 경우) 무엇이 잘못되었는지 이해할 수 없다. SQL 쿼리는 괜찮습니다. 파일 (Phpgraphlib.php, graph.html 및 graph.php)은 777 권한 (파일 및 디렉토리)이있는 동일한 디렉토리에 있습니다.

도와 주시겠습니까?

덕분에 내가 GD를 설치하는 것을 잊었다

답변

0

조르지오. 설치 한 후 작동하기 시작했습니다.