I want to store a Javascript object as a polygon in a Mysql database.
I can define start and end points of x and y to give me four corners:

```
var polygon = [
    xstart +' '+ ystart,
    xend +' '+ ystart,
    xend +' '+ yend,
    xstart +' '+ yend,
    xstart +' '+ ystart
];

```

I can format this object as a string

```
polygon = "ST_GeomFromText('POLYGON(("+ polygon.toString() +"))'";

```

When I insert this into a Mysql database

```
INSERT INTO `caption` (`caption_id`, `caption_area`) VALUES (NULL, '\'POLYGON((0.28 0.33,0.35 0.33,0.35 0.45,0.28 0.45,0.28 0.33))\'')

```

the query fails

```
#1416 - Cannot get geometry object from data you send to the GEOMETRY field

```

How can I format the Javascript object, or the query, to correctly insert a polygon in to a database?