-1

I have did it for PHP older versions:

<?php require_once('Connections/SQLConn.php');
mysql_query("SET NAMES 'utf8'"); ?>

Now i want to update this obsolete code in order to update to PHP 5.6, well i tried with htmlentities(), htmlspecialchars(), changing by mysqli and it doesn't work.

example of typical black rhombus

My local database is collated by latin1_swedish_ci because my website is ready for both Spanish and English languages, and every single table of my db are collated by utf8_spanish_ci (if necessary for you to know it).

danibeam
  • 29
  • 6
  • 2
    *latin1_swedish_ci because my website is ready for both Spanish and English languages* ... and that seems logical to you does it, as opposed to say utf8_general_ci (especially since you're then setting utf8 every table individually)? – CD001 Mar 29 '16 at 15:34
  • 2
    Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – CD001 Mar 29 '16 at 15:35
  • @CD001 I've just set every table individually to latin1_swedish_ci and still the same problem. – danibeam Mar 29 '16 at 16:18
  • Come on guys, don't close this question! – Rick James Mar 29 '16 at 23:44

1 Answers1

0

Do not use the mysql_* API. Switch to PDO or mysqli_*. In the latter statement is $conn->charset('utf8');

The black rhombus is usually caused by

  • The encoding of the text in the client is latin1
  • The connection (as being discussed) is latin1
  • The table column may be either latin1 or utf8 (either has the same effect)
  • The HTML code says <meta ... charset=UTF-8>

You need to either go latin1 all the way, in which case the charset in meta needs to be ISO-8859-1. Or go utf8 all the way.

Spanish works 'equally' well in latin1 as in utf8. But if you go east of western Europe, latin1 will be inadequate.

Since you have been messing around, please check what is in the table. ñ should be hex F1 if CHARACTER SET latin1, or C3B1 if utf8. If you see C3B1 in a latin1 table, you have another problem.

Rick James
  • 135,179
  • 13
  • 127
  • 222