title: Inserting spatial data into MySQL database
body: <p>I tried to insert data into point() datatype column from PHP this way:</p>
  
  <pre><code>INSERT INTO table (coordinates) VALUES ("48.20 14.80");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>INSERT INTO table (coordinates) VALUES ("POINT(48.20 14.80)");
  </code></pre>
  
  <p>And then I applied triggers before every insert or update:</p>
  
  <pre><code>BEGIN
  SET @lat = SUBSTRING(NEW.coordinates, 1, LOCATE(' ', NEW.coordinates));
  SET @lng = SUBSTRING(NEW.coordinates, LOCATE(' ', NEW.coordinates) + 1);
  SET @coor = PointFromWKB(POINT(@lat, @lng));
  SET NEW.coordinates = @coor;
  END
  </code></pre>
  
  <p>or</p>
  
  <pre><code>BEGIN
  SET NEW.coordinates = GEOMFROMTEXT(NEW.coordinates);
  END
  </code></pre>
  
  <p>But it returns:</p>
  
  <pre><code>SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field
  </code></pre>
  
  <p>Does anyone of you know what's the problem? Thanks.</p>