I wrote a few lines of code just to detect any problems and I unfortunately did. The following code returns an empty JSON array, only two square brackets with no content between them. I tried using geo with valid,existent values from the table places. Although, it works perfectly when I send these commands directly in the SQL tab at phpMyAdmin.

// TODO: search database for places matching $_GET["geo"]
$geo = $_GET["geo"];

if(ctype_alpha($_GET["geo"]) === TRUE)
    $alpha_match = query("SELECT * FROM places WHERE MATCH(place_name, postal_code, admin_name1) AGAINST (? IN BOOLEAN MODE);",$geo);
else if(is_numeric($_GET["geo"]) === TRUE)
    // do something

Below is how I've indexed my columns:

enter image description here

EDIT: This is what I receive:

enter image description here

  • Does your query return rows if your search term ($_GET["geo"]) is rome? I think I see the problem but I want to be sure before I dive in. – DinoCoderSaurus Dec 18 '15 at 21:29
  • No, anything I type returns empty. – Gabriel Dec 18 '15 at 21:49
  • Even "asdafafasd" returns an empty JSON array. – Gabriel Dec 18 '15 at 22:03
  • Well asdafa.... wouldn't match anything, so you should expect an empty array. What "geo" do you use when you test directly in SQL? When you say empty JSON array, do you mean $alpha_match? Are you transferring the data from $alpha_match to $places? Correctly? – DinoCoderSaurus Dec 18 '15 at 22:38
  • I've edited my post to what I receive and an example of what "geo" I use. In SQL I've hardcoded "Cambridge" and other variants that include "MA",full state name and postal code for testing purposes. – Gabriel Dec 18 '15 at 22:43

I've just realised I had to put $places instead of $alpha_match. I should've paid more attention to the code below of how the JSON is created. facepalm

  • Glad to hear it. It's time for dinner anyway :) – DinoCoderSaurus Dec 18 '15 at 22:57
  • Sorry for wasting your time. Cheers ! :) – Gabriel Dec 18 '15 at 22:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .