0

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?

RGriffiths
  • 5,722
  • 18
  • 72
  • 120
  • Are you sure it really works on the server? It might be possible that it's throwing the same warning / error but you don't notice because error reporting is turned off on the server! Also is there a different PHP version on the server? – jrswgtr Feb 23 '20 at 12:11
  • @jrswgtr It is possible settings are different on the server but if I turn off warnings on XAMPP I still do not get through to a graph being displayed with the fatal error. Whereas the hosting version I get the chart.as expected. – RGriffiths Feb 23 '20 at 12:13

1 Answers1

1

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.

Dan
  • 11
  • 2