-1

I've been struggling with this for a while. I'm building a web site in PHP and MySQL. But the way that special characters such as "öäüß" behave is oddly random!

I'm using these encodings:

  • PHP Files: Unicode (UTF-8 with signature) Codepage 65001 (Saved in VS2012, PHP-Tools for VS Plugin)
  • Database fields: latin1_swedish_ci (I also tried several others)
  • HTML: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Bugs

  • When I enter special characters in phpMyAdmin, they look bad on the web site
  • When I insert them with INSERT from a $_POST variable, they look good on the web site but bad in phpMyAdmin
  • When I deploy the result on a remote server, special characters look bad in both phpMyAdmin and on the web site.

Question

I have the feeling that I'm doing something terribly wrong here and that changing some encoding here and there will not eventually solve this issue.

Any suggestions where to set what encoding?

bytecode77
  • 14,163
  • 30
  • 110
  • 141
  • Your database uses a different encoding than your PHP code and HTML output. What could go wrong? In any case, this question is far too lacking in specifics to get a definite answer. – Jon May 07 '13 at 18:27
  • I said I tried other encodings for the database and that they were also not working. Is that your down vote? – bytecode77 May 07 '13 at 18:27
  • It's not, but I wouldn't be obliged to justify it even if it were. The closevote is mine. – Jon May 07 '13 at 18:29
  • Like I said, I tried UTF-8 encoding for the database fields but it didn't help... – bytecode77 May 07 '13 at 18:30
  • And like I said, the question is far too lacking in specifics. Consider this when looking at the kind of answers you will be getting, if any. – Jon May 07 '13 at 18:33
  • I got an answer and it solved my problem duh.... – bytecode77 May 07 '13 at 18:35
  • Also, how is the possible duplicate question any more specific than mine? – bytecode77 May 07 '13 at 18:36
  • @DevilsChild: I don't especially think it is; it's just that the answers are already there and at least one of them is pretty comprehensive. – eggyal May 07 '13 at 18:37

1 Answers1

2

Try executing below query once after your connection to database

SET NAMES UTF8
Sid
  • 560
  • 7
  • 17