I am building a script that will generate a map image based on coordinates it gets from a MySQL database. The coordinates are stored as comma separated values in a field in the database (i.e. “292,45,366,49,366,68,346,88,311,86” is stored in one field). The imagepolygon() expects the coordinates to be an array. I am using the following script, but I am getting an error that it is not an array:
$coords = array(mysql_result($result, $j, coordinates)); coordinates = “292,45,366,49,366,68,346,88,311,86”
I then load this into the imagepolygon() function like so:
imagepolygon($masterMap, $coords, $points, $color);
This produces the following error:
imagepolygon() [function.imagepolygon]: 2nd argument to imagepolygon not an array in /home/public_html/createMap.php on line 47
If I rewrite the function as follows, it works but is obviously not a workable solution:
imagepolygon($masterMap, array(292,45,366,49,366,68,346,88,311,86), $points, $color);
Any ideas?