0

I can't seem to find where documented to successfully prepare a statement that uses the POINT data type.

This previous question (How to use POINT mysql type with mysqli - php) shows something marked as correct, but it doesn't work. I even tried using their simple query in their example:

$stmt = $this->conn->prepare("INSERT INTO days(day,POINT(lat,lon)) VALUES(?,?,?)");
$stmt->bind_param("sdd", $day, $lat, $lon);

This just simply returns and error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(lat,lon)) VALUES(?,?,?)' at line 1
1
  • 2
    INSERT INTO days(day,point) VALUES(?,POINT(?,?))!? Commented Mar 29, 2017 at 12:47

1 Answer 1

2

Try like below;

$stmt = $this->conn->prepare("INSERT INTO days(day,column_name) VALUES(?,POINT(?,?))"); //column_name is name of of column that you want to insert POINT(lat,lon)
    $stmt->bind_param("sdd", $day, $lat, $lon);
    $stmt->execute();
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Thank you very much :-) I can't believe I couldn't find that documented anywhere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.