0

I need help passing a complex string representing a polygon to a php script where the string is used in an SQL query. The proper format is to enclose the entire POLYGON statement in single quotes. The PHP script isn't catching the $_POST variable. What could be the reason?

Javascript:

var polyBoundary = "'POLYGON ((-98.13787244260311 30.031055426540206, -95.98455213010311 31.970803930433096, -92.18328259885311 27.89734922968426, -95.69890759885311 26.49024045886963, -98.13787244260311 30.031055426540206))'";

$.post("php/insertPolygon.php", {boundary: polyBoundary}, function (data) {
    alert(data) // this alert never fires
    // Do stuff with the response
}, "json");

PHP:

<?php
    $prjBoundary = $_POST['boundary']; # I'll sanitize once I get everything working
    # Connect to DB, execute SQL query, etc.

    # Make sure I'm sending a response no matter what
    if ( ($errors = sqlsrv_errors() ) !=null) {
        echo "Error!";
    } else {
        echo "SUCCESS!"; # this should have been echo json_encode("SUCCESS!");
    }

PHP Error: Undefined index: boundary in FILENAME on line 2

Roy
  • 1,468
  • 4
  • 21
  • 40

0 Answers0