0

Can someone please explain something to me, as i'm struggling to understand what i'm doing wrong?

At the moment both of my php/html file and my mysql database have matching Charsets, both UTF-8. My php.ini file shows UTF-8 as the default and i'm even setting it in a meta tag just to make sure its definitely correct.

<meta charset="utf-8" />

If i run this code,

SELECT * FROM information_schema.SCHEMATA WHERE schema_name = "my_database";

on my database, it returns utf8 as the character set.

Now I have a column in my database which contains a £ symbol, but whenever i'm fetching it in php and displaying it on my site, its showing as a black diamond with a question mark inside it.

Why is it not showing the correct characters when both my php and mysql character sets are matching?

Also, another quick question as i'm quite new to this, what is the current default character set. What should i be aiming to have all of my sites run on? UTF-8, ISO-8859-1 or something else?

S_R
  • 1,818
  • 4
  • 27
  • 63
  • 1
    Your database should use `utf8mb4`, not `utf8`. This doesn't affect the `£` symbol but it will affect other things. – Niet the Dark Absol Aug 17 '18 at 09:23
  • May i know how you connect to database? – Zendy Aug 17 '18 at 09:36
  • @Zendy The site itself is quite old, so its using php5.6 and `mysql_connect()` – S_R Aug 17 '18 at 09:40
  • Change away from PHP's `mysql_*` interface to `mysqli_*` or `PDO` ! See black diamonds in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Aug 22 '18 at 22:01

0 Answers0