// sample code // misc snippets from chapter 7 “SET NAMES utf8”) ); // set the error reporting attribute to throw Exception . $db->setAttribute( PDO::ATTR_ERRMODE , PDO::ERRMODE_EXCEPTION ); //The following code will read the query string and put the parameters into an array named $value: // Put needed parameter names from GetPOI request in an array called $keys. $keys = array( “layerName”, “lat”, “lon”, “radius” ); // Initialize an empty associative array. $value = array(); try { // Retrieve parameter values using $_GET and put them in $value array with // parameter name as key. foreach( $keys as $key ) { if ( isset($_GET[$key]) ) $value[$key] = $_GET[$key]; else throw new Exception($key .” parameter is not passed in GetPOI request.”); }//foreach }//try catch(Exception $e) { echo ‘Message: ‘ .$e->getMessage(); }//catch //Now you need to prepare your response that will display the POIs to the user: // Create an empty array named response. $response = array(); // Assign cooresponding values to mandatory JSON response keys. $response[“layer”] = $value[“layerName”]; // Use Gethotspots() function to retrieve POIs with in the search range. $response[“hotspots”] = Gethotspots( $db, $value ); // if there is no POI found, return a custom error message. if ( empty( $response[“hotspots”] ) ) { $response[“errorCode”] = 20; $response[“errorString”] = “No POI found. Please adjust the range.”; }//if else { $response[“errorCode”] = 0; $response[“errorString”] = “ok”; }//else