MySQL Spatial Data – Insert GEOMFROMTEXT (lat lng)

MySQLPHPspatial

I am stuck, please help. The following SQL statement works:

"INSERT INTO  `routeplans` (  `polygon` ) 
VALUES (
GEOMFROMTEXT( 'POLYGON(
(39.593254951279626 -119.2415714263916,
 39.596231192849004 -119.2441463470459,
 39.59742165367196 -119.2287826538086,
 39.601786501640284 -119.24200057983398,
 39.604497859585535 -119.23067092895508,
 39.60608494668563 -119.23830986022949,
 39.593254951279626 -119.2415714263916)))' )
)"

However, when I submit the query from php I get the following error:

Numeric value out of range: 1416 
Cannot get geometry object from data you send to the GEOMETRY field
(SQL: insert into `routeplans` (`polygon`) values
(GEOMFROMTEXT('POLYGON((39.593254951279626 -119.2415714263916,
39.596231192849004 -119.2441463470459,39.59742165367196
-119.2287826538086,39.601786501640284 -119.24200057983398,
39.604497859585535 -119.23067092895508,39.60608494668563 
-119.23830986022949,39.593254951279626 -119.2415714263916)))')))

Best Answer

The following did the trick. Laravel raw expressions.

DB::raw('GeomFromText(\'POLYGON('.$polycoords.')\')