Reputation: 618
I am making a website which has a database where I store data which contains the symbols ÅÄÖ (I don't know if they will show up here, but if they don't, they are "special symbols"). However when I retrieve the data from the SQL database and outputs it on the webpage, all of the special symbols ÅÄÖ are replaced by �, (black squares with questionmarks inside of them). I have tried to change the collation in which the data are stored back and forth between utf8_swedish_ci and latin1_swedish_ci. But it does not work. I don't think there are any wrong with the website itself since it can output these symbols if you write them directly into the html document.
Thanks
Upvotes: 0
Views: 852
Reputation: 821
If you store the collation as utf8_swedish_ci, then set the characterset in PHP as follow as :
$con=mysqli_connect("host", "user", "pw", "db");
if (!$con)
{
die('Failed to connect to mySQL: ' .mysqli_connect_errno());
}
/* change character set to utf8 */
$con->set_charset("utf8");
After adopting above in changes in your PHP code, If you still face the problem then change the collation as utf8_unicode_ci which is more accurate in sorting.
Hope your query get resloved by adapting above necessary changes.
Thank you.
Upvotes: 0