pChart Library and PHP: class pDraw not found although it exists

516 Views Asked by At

I want to use the pChart Library (https://github.com/bozhinov/pChart2.0-for-PHP7) to draw some graphs based on a MySQL Dataset. Therefore I'm including a PHP file which contains the MySQL Query and the pChart code for drawing the graphs in another page. This is the page structure:

main page ski.php
|- msqry.php: MySQL Query and pChart code

Currently I'm struggling with including the necessary pChart class files. On top of msqry.php I'm including the classes:

$filenameclass1 = $_SERVER["DOCUMENT_ROOT"] . "/pchart/pChart/pColor.php";
if(file_exists($filenameclass1)) {
    include($_SERVER["DOCUMENT_ROOT"] . "/pchart/pChart/pColor.php"); 
} else {
    echo "Class pColor not found";
}
 
$filenameclass2 = $_SERVER["DOCUMENT_ROOT"] . "/pchart/pChart/pDraw.php";
if(file_exists($filenameclass2)) {
    include($_SERVER["DOCUMENT_ROOT"] . "/pchart/pChart/pDraw.php"); 
} else {
    echo "Class pDraw not found";
}

$filenameclass3 = $_SERVER["DOCUMENT_ROOT"] . "/pchart/pChart/pCharts.php";
if(file_exists($filenameclass3)) {
    include($_SERVER["DOCUMENT_ROOT"] . "/pchart/pChart/pCharts.php"); 
} else {
    echo "Class pCharts not found";
}

All three files exist and are included successfully (since I'm not getting any echos saying 'Class xxx not found'). When creating a new pDraw object:

$anab_dgr = new pDraw(700, 230);

I'm getting this error: "Fatal error: Uncaught Error: Class 'pDraw' not found in msqry.php ..."

So obviously the class cannot be found by PHP although the file exists and is included within the current file. What am I missing here?

Any help is very much appreciated.

Edit I forgot to mention that the examples provided in the above github repository are working as expected.

0

There are 0 best solutions below