Giorgio Torassa
Giorgio Torassa

Reputation: 75

Phpgraphlib: internal server error

I'm trying to visualize a graph on my web page using Phpgraphlib. I use the following code:

PHP Script (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 page (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>

It is very simple but I get a 500 Internal Server Error. I know that the PHP script is read by the server (if I put a semantic error on the PHP script I see it on the apache log), so I can't understand what is wrong. The SQL query is ok, the files (Phpgraphlib.php, graph.html and graph.php) are in the same directory with 777 permission (files and directory).

Can you help me?

thanks giorgio

Upvotes: 0

Views: 193

Answers (1)

Giorgio Torassa
Giorgio Torassa

Reputation: 75

I forgot to install GD. After I installed it, it started working.

Upvotes: 0

Related Questions