I want to save the JSON coordinates of polygon in the PostGIS database. This is my PHP code-
$coordinates = ($_POST['Coordinates']);
$query = "INSERT INTO table_name (column_name) VALUES
(ST_SetSRID(ST_GeomFromGeoJSON ('{
['".($coordinates) ."']
}'), 4326))"
$success = pg_query($conn,$query);
where Coordinates are-
{"type":"polygon","coordinates":[[[-97.53662109375,43.67581809328341],[-98.096923828125,42.60970621339408],[-96.427001953125,42.924251753870685],[-97.53662109375,43.67581809328341]]]}
but the error is- "Parse error: syntax error, unexpected '$success' (T_VARIABLE)" column_name is polygon type column in table.
please someone correct me how to resolve syntax error. Thanks.