Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Latin characters in phpMyAdmin with UTF-8 collation

My website uses:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

And this meta:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I created my database and tables in phpMyAdmin making sure everything is set as utf8_unicode_ci (table, fields, database), even the connection collation.

When I insert some latin characters (accents, ñ and stuff like that) into the database using an standard form made in PHP, it works fine, I can display the saved data in my website no problem. But if I go to phpMyAdmin, all the latin characters are all messed up, something like ñññ.

If I try to fix that data in phpMyAdmin, then my website displays the data incorrectly, with weird symbols ���.

What in this world am I doing wrong? I've been trying to work this out for hours with no success.

Thank you all!

like image 821
Dan H Avatar asked Dec 17 '22 00:12

Dan H


1 Answers

As @Artefacto says, this could be a problem local to phpMyAdmin.

If phpMyAdmin is fine (i.e. set to UTF-8) and the data is still showing up weird, then look at whether your database connection using UTF-8 as well?

mysql_query("SET NAMES utf8") 

(or whatever you use as a database library) might help if it isn't.

like image 144
Pekka Avatar answered Jan 13 '23 18:01

Pekka