progNewbie
progNewbie

Reputation: 4812

Umlauts and special characters are not displayed in php mysql

I have written a small social network on my pc in my localhost xampp. Here everything works fine.

Text in my mySQL Database looks like this: "was für pizza?" instead of "was für Pizza?". This is fine, it is displayed like "was für Pizza?" in my localhost on my PC.

But now I uploaded it to my Webspace and there I got this "was für pizza?" displayed.

Can anyone help me?

Upvotes: 0

Views: 1913

Answers (3)

Flavio Vinho
Flavio Vinho

Reputation: 23

You can convert the file to UTF8 using notepad plus plus. Try it.

Upvotes: 0

Navarr
Navarr

Reputation: 3764

Some steps:

  • Make sure your table/columns are set to a unicode collation. An older, but still good one is utf8_unicode_ci. It works for most cases, but if you're going to have emoji (which you might with a social network) you'll want to use utf8mb4_unicode_ci.
  • Make sure that PHP's connection with the database is UTF8. This is generally accomplished by running the query SET names 'utf8'
  • Make sure your website is telling the browser that it's UTF8. This is generally accomplished by sending the Content-Type: text/html;charset=utf-8 header, by including a meta tag that says the same thing, <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> or by including a meta-charset tag (newer) <meta charset="utf-8" />

Upvotes: 2

Useless Intern
Useless Intern

Reputation: 1302

This sounds like an issue with character encoding, you need to use utf-8. I think the default is ascII. I only write pages in English but this guy has all of the steps needed.

Upvotes: -1

Related Questions