First, are you using $_POST and not $_GET? PHP has some weirdness with $_POST requests at times. You can put come echo statements or print_r()'s in your PHP script to make sure $_POST[] is actually being populated.
HTTP requests are known as VERBS: GET, POST, PUT, DELETE, and a few others. There are two concepts when deciding to use POST vs GET. First is data size. GET is limited to around 200 characters or so in the URL after the ?. POST has a much larger limit. Since you’re only sending a couple of numbers, GET is a much easier way to deal with this. The next is semantics. The verbs are named the way they are for a reason. If you think of database options: CREATE, READ, UPDATE, DELETE (CRUD). These kind of map to POST, GET, PUT, DELETE. That is GET is for getting data fro the server. POST is for sending data to the server. Some people use PUT for updating.
Semantically speaking you are GETting a list of location matches cased on a couple of parameters.
Also switching to get means not dealing with the params table which will simplify your code.
local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) alert = native.showAlert( "No GPS Signal", "Can't sync with GPS.", { "Okay" } ) -- this is not true. .isError will be true if the server timed out or could not be reached. -- It has nothing to do with the GPS. else print ( "Upload complete!" ) -- you're not really uploading anything myTable = json.decode(event.response) addressBar.text = myTable.barberid .. myTable.barberid .. myTable menu.title.text = myTable[1].barberid .. myTable.barberid .. myTable --these are all just for testing to see if im getting the right info back from the network response --alert = native.showAlert("test", myTable[1].barberid, { "Okay" } ) --alert = native.showAlert("test", myTable.barberid, { "Okay" } ) end end local params = {} params.headers = headers -- what are your headers? --handler for a test button4 local function testEvent(event) local phase = event.phase if phase == "ended" then --currentLocation is defined earlier from the map:getUserLocation local URL = "http://107.170.34.199/barber\_search\_script.php?" .. "currentLat=" .. currentLocation.latitude .. "¤tLng=" .. currentLocation.longitude network.request( URL, "GET", networkListener, params) return true end return false end
I added some comments in line. Change your PHP script to use $_GET[]; and I think you will be in business. If not, and you get .isError you need to print out event.response and event.status to get a clue as to why it failed. If .isError is false, and you’re not getting what you expect you should print out event.response and see what your script is really sending back.