184.108.40.206. Invalid encoding when outputting data from the database
If the encoding of the site and the database does not match (some of the text on the site is displayed normally, and some of the text from the database is in the form of incomprehensible characters), you need to add commands in the script that connects to the database that will indicate the encoding to the MySQL server in which you want to display the text. Depending on which PHP library you are using, the commands will look like this:
utf8you must specify the desired encoding (for example,
utf8_general_ci— the desired encoding mapping (for example,
cp1251_general_ci). A complete list of MySQL encodings and collations is available at official documentation.
- For the library mysqli the first parameter specifies a pointer to the connection to the database — in your script it may be different from
$link(you can find it out by looking in the source code for the name of the variable to which the result of the function is assigned