pChart working at host server but not XAMPP: Uncaught Error: Cannot use string offset as an array

648 Views Asked by At

I am using pChart to generate some charts and this working fine when run at the server but when I run the same on XMAPP I get this error:

Warning: Cannot assign an empty string to a string offset in ...\pDraw.class.php on line 4990

Fatal error: Uncaught Error: Cannot use string offset as an array in ...\pDraw.class.php:4991

The line referred to in pDraw.class.php is:

4990 if ( !isset($LastX[$Key] ) ) { $LastX[$Key] = ""; }
4991 if ( !isset($LastX[$Key][$Pos] ) ) { $LastX[$Key][$Pos] = $YZero; }

$Last is referred to earlier in the function as a string ($LastX = "";) and here it is being set to an array. If I add the following just before 4990:

var_dump($LastX);
echo " : Key = " . $Key;
if (!is_array($LastX)) {
    echo " : Not array";
}

I get:

string(0) "" : Key = 3 : Not array

As said it works on the server side but I would like to get it working on XAMPP. I know I could use a different graph library but I am trying to understand this issue. Any ideas or is this just badly written?

1

There are 1 best solutions below

0
Dan On

This problem purely down to the php version you are running on. Your server must have an old version of php such as 5.6 and local may have higher version.

Either try lower version of php locally or upgrade your pChart package here if you running latest php7.