Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    408
    Thanks
    17
    Thanked 2 Times in 2 Posts

    fulltext search syntax and error

    I'm trying to figure out how to build a fulltext search and I'm not sure if I've built my query right. I'm getting this error: Query failed: Unknown column 'searched term' in 'field list'"

    Which is confusing, because I' thought that spot is where you put the searched term - not a column.

    Code:
    $item = $_REQUEST['searched_term'];
    $query = "SELECT *, MATCH(scientific_name, common_name_english) AGAINST ($item) AS score from table WHERE MATCH (scientific_name, common_name_english) AGAINST($item) order by score desc";
    	//$data = mysql_query("SELECT * FROM table WHERE common_name_english LIKE '%$item%'");
    
    $data = mysql_query($query);
    if ($data === FALSE) {
          die("Query failed: " . mysql_error());
    }

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    408
    Thanks
    17
    Thanked 2 Times in 2 Posts
    nevermind... it seems it was just a lack of apostrophes around the variable $item


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •