An old page has the current setup:
- MySQL DB and tables:
latin1_swedish_ci
- HTML:
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
Everything works fine for years now.
Now I have downloaded the PHP files from FTP, updated the code and because my editor uses UTF8 I have issues with the presentation of the text from the PHP files.
If I change to <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
the text from HTML files is displayed properly but not the text from the database.
If I set the DB and tables to utf8_bin
and import data via file_get_contents() > $mysqli->set_charset('utf8') > $mysqli->multi_query($sql_file)
, the text is presented correctly.
But the %LIKE%
search does not work anymore?
I think UTF8 is more straightforward. What are the correct steps to solve this issue?
CodePudding user response:
try to use utf8mb4_general_ci for DB tables and try to set correct charset for your DB connection. First SQL query to DB:
$sql = "SET NAMES utf8mb4";
after that run your SQL query