1

I'm having problems with Pound Signs appearing as Question Marks within a diamond in my PHP script which pulls data from a MySQL Database.

I have looked through other Stack Overflow answers and I think checked everything.

I have checked in php.ini that I have default_charset = "utf-8", I have also added AddDefaultCharset UTF-8 to /etc/apache2/apache2.conf and to /etc/apache2/conf-enabled/charset.conf

I have also added this to the top of the web page:

<!DOCTYPE html>
<html lang="en">
<HEAD>
<meta charset="UTF-8">
<title>ZXDB</title>
</HEAD>
<BODY>

Finally I ran sudo /etc/init.d/apache2 restart to restart the server.

I'm using Ubuntu 16.04 with Apache and PHP7.

What am I missing?

The page is available here:

http://spectrumcomputing.co.uk/originalprices.php

Thank you in advance

2 Answers2

1

Thanks everyone for their answers. Even though the database, the table and the field were all set as UTF-8, when I checked the Character set with this:

http://php.net/manual/en/mysqli.set-charset.php

It said it was Latin, so I fixed it with adding this to my PHP

mysqli_set_charset($conn,"utf8");

Where $conn is your connection string

Peter

0

Is £ showing up as a single ? If so, see "Black diamond" in https://stackoverflow.com/a/38363567/1766831 . That says:

Case 1 (original bytes were not UTF-8):

  • The bytes to be stored are not encoded as utf8. Fix this.
  • The connection (or SET NAMES) for the INSERT and the SELECT was not utf8/utf8mb4. Fix this.
  • Also, check that the column in the database is CHARACTER SET utf8 (or utf8mb4).

Case 2 (original bytes were UTF-8):

  • The connection (or SET NAMES) for the SELECT was not utf8/utf8mb4. Fix this.
  • Also, check that the column in the database is CHARACTER SET utf8 (or utf8mb4).

Black diamonds occur only when the browser is set to <meta charset=UTF-8>.

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