My-Little-Forum / mylittleforum

A simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure)
GNU General Public License v3.0
118 stars 47 forks source link

Set the character encoding with the proper PHP function #694

Closed auge8472 closed 4 months ago

auge8472 commented 4 months ago

Until now we set the character set encoding of the database connection with the query SET NAMES utf8mb4. As the manual page of the function mysqli_set_names states, is the use of the function preferred over the use of the above mentioned query for this purpose because the function changes more than only the charset of the connection itself.

But the function does not set a collation for the connection (defines the sorting of ordered query results). When the collation is not explicitely set to a defined value, the default value configured on the specific server is used instead.

This is described in a few of the user comments on the bottom of the manual page for the function mysqli_set_charset wich also provide a method to solve the problem. To unify this, we have keep the query and have to enhance it with setting a specific collation.

The selected collation might be replaced later if and when we encounter a problem with the sorting of results.

See also #693