Hello, doing kinosayt screwed up the search, but there was a very strange mistake. When you request " Major 2 " and any other request of this format ( Godfather 2, Godfather 3 ) does not give anything through a request in PHP. I tried to search directly through phpMyAdmin, but I also did not find it there, although I have movies in the database. I thought that it was in the presence of numbers, but then he introduced " 1408 " and he perfectly found the film. And if I enter a query without numbers and spaces, for example, " Major " or " The Godfather ", then everything is displayed in a heap with other results where the entry was.

$search = $_POST['q']; $getName = mysql_query("select id,name_ru,name_en,year,description from all_list WHERE CONCAT (name_ru,name_en) LIKE '%$search%' ORDER BY kp_rating DESC LIMIT 5"); 

Fields have type "Text", comparison "utf8_general_ci". Please help me figure it out.

  • one
    "The Godfather" - is it without numbers and spaces?) - P. Fateev
  • Yes it is without numbers and spaces - yaslik
  • And between the first and the second word - what kind of a character would you tell me?) - P. Fateev
  • If there is a space between words, the search works fine (for example, the Godfather), but if at the end between the word and the number, it does not find anything (for example, Godfather 2). - yaslik
  • Does the database have exactly one space before the numbers? - P. Fateev

1 answer 1

The problem was that when I added data to the database I registered htmlspecialchars and therefore added "   ". Made a complete database UPDATE and now everything is in order. To replace "   " used:

 $stroka = htmlentities($row['stroka'], null, 'utf-8'); $stroka = str_replace(" ",' ',$stroka ); $stroka = html_entity_decode($stroka);