Answer the question
In order to leave comments, you need to log in
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());
}
?>
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question