0

I have a site where text from a mysql database is retrieved and displayed on a page. Someone wrote:

 "Can't wait to meet him (smiley emoticon)"

It displays fine on the first site, but I copied the database over to another site and when that second site displays it, it adds weird characters, like this:

"Can’t wait to meet him😉"

Why would the same info from two mysql databases display differently? I obviously would like the second site to show it how it appears on the first site.

The first site echoes it back like this:

 echo "<span class='comment'>" . $row['comment'] . "</span>";

The second site uses htmlspecialchars, which I thought was the right way?

echo "<div class='comment'>" . htmlspecialchars($row['comment']) . "</div>";

What am I missing here?

FYI, only difference I can think of is that I used mysqli to retrieve it on first site, and am using PDO to do so on the second site. Not sure if that could explain anything.

user3304303
  • 1,027
  • 12
  • 31
  • When you duplicated the mysql database, you are sure the encoding types never changed? Also on the second site, its html headers and definitions use the same character set as the first site? – IncredibleHat Nov 30 '17 at 02:21
  • Both sites have "content="text/html; charset=utf-8" in the headers. The collation is both "latin1_swedish_ci, is that the encoding? (Sorry not super familiar with mysql obviously). – user3304303 Nov 30 '17 at 02:39

0 Answers0