0

I don't know why this results in no rows although I am being blind cautious about any errors. Can anybody pick up the reason for this? sorry the code is quite loquacious I found it the simplest way.

if(strpos($_GET["geo"], " ") !== false && strpos($_GET["geo"], ",") !== false)
{
  $pieces = explode(", ", $_GET["geo"]);
  if (count($pieces) === 4)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? +? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1], $pieces[2], $pieces[3]);
  if (count($pieces) === 3)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1], $pieces[2]);
  if (count($pieces) === 2)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1]);
}
else if(strpos($_GET["geo"], " ") !== false)
{
  $pieces = explode(" ", $_GET["geo"]);
  if (count($pieces) === 4)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? +? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1], $pieces[2], $pieces[3]);
  if (count($pieces) === 3)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1], $pieces[2]);
  if (count($pieces) === 2)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1]);

}
else if(strpos($_GET["geo"], ",") !== false)
{
  $pieces = explode(",", $_GET["geo"]);
  if (count($pieces) === 4)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? +? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1], $pieces[2], $pieces[3]);
  if (count($pieces) === 3)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1], $pieces[2]);
  if (count($pieces) === 2)
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? +? IN BOOLEAN MODE)", $pieces[0], $pieces[1]);
}
else
{
  $pieces = $_GET["geo"];
  $places = query("SELECT * FROM `places` WHERE MATCH (`country_code`, `place_name`,`admin_name1`,`admin_name2`,`postal_code`, `admin_code1`) AGAINST (+? IN BOOLEAN MODE)", $_GET["geo"]);
}

strong text

2

When I am trying to figure out what SQL commands to use, I use phpmyadmin to execute the SQL commands first, for instance the Search tab for SELECT and the Insert for INSERT. Once I have the results I am looking for, I paste the SQL statement generated by phpmyadmin into the SQL tab to try it out. Only when that works do I attempt to implement the SQL statement in my code. I find this approach saves me a lot of time, and hope this helps you.

You must log in to answer this question.

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