Implemented a search in mySQL, until I encountered the problem of the impossibility of searching using Cyrillic.
$str = '%'.$_GET['s'].'%'; $pdo = new PDO(подключение); $sql = "SELECT * FROM clients WHERE id LIKE ? OR order_id LIKE ? OR datetime LIKE ? OR name LIKE ?"; $sth = $pdo->prepare($sql); $sth->execute(array($str, $str, $str, $str)); while($row = $sth->fetch()) { $clients[] = $row['id']."|".$row['order_id']."|".$row['datetime']."|".$row['name']; } An Illegal mix of collations for operation 'like' error occurs. I also tried to add, but did not give anything.
datetime LIKE ? COLLATE utf8_unicode_ci In mySQL settings
mysql> SHOW VARIABLES LIKE 'collation%'; +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_unicode_ci | | collation_server | utf8_unicode_ci | +----------------------+-----------------+ Using datetime is necessary, but errors occur with it. Please suggest how to fix the error :)
datetime- Alexei ShimanskydatetimeThen it’s not about Cyrillic ... maybe then you should first check that there’s a get request and from that either execute the request without adatetimeor concatenate it to the request - Alexey ShimanskyGETfor the characters you need. Type if not a number - then do nothing - Alexey Shimansky