S
S
SinSin352020-05-06 22:00:57
PHP
SinSin35, 2020-05-06 22:00:57

How to search Cyrillic in Mysql x PHP?

There is a table of goods in Mysql, when I do a search using English letters, everything is fine, but when I search for Russian words, it doesn’t work. As I understand it, it’s in the encoding, but I don’t understand what and where exactly to change.
in phpmyadmin db I have in utf8mb4_unicode_ci encoding.
Database connection:

<?php 
$dbServername = "localhost";
$dbUsername="root";
$dbPassword="";
$dbName="kursor";

$conn=mysqli_connect($dbServername,$dbUsername,$dbPassword,$dbName);

if (!$conn){
  die("Connection failed: ".mysqli_connect_error());
}

?>


The request itself:
else if(isset($_POST['MainSearch'])){
  $searchq=$_POST['MainSearch'];
  $searchq=preg_replace("#[^0-9a-zа-я]#i", "", $searchq);
  $sql="SELECT * FROM product INNER JOIN categories USING(Prod_id_type) WHERE ((Prod_name LIKE '%$searchq%')||(Prod_opis_min LIKE '%$searchq%'));";
}
$result = mysqli_query($conn,$sql);
$resultCheck = mysqli_num_rows($result);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
unwrecker, 2020-05-07
@SinSin35

And in what encoding is the base itself and in what encoding does PHP work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question