Phpgraphlib を使用して、自分の Web ページでグラフを視覚化しようとしています。次のコードを使用します。
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();
?>
Web ページ (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 Internal Server Error が発生します。PHPスクリプトがサーバーによって読み取られることはわかっているため(PHPスクリプトにセマンティックエラーを配置すると、Apacheログに表示されます)、何が問題なのか理解できません。SQL クエリは問題ありません。ファイル (Phpgraphlib.php、graph.html、graph.php) は同じディレクトリにあり、777 のアクセス許可があります (ファイルとディレクトリ)。
手伝って頂けますか?
ありがとうジョルジオ