0

Okay, so I know this has been discussed millions of times. And I've seen billions of attempts to solve the problem. And in most cases they have. But in my case, something still doesn't want to work.

I have ALL my files encoded with utf-8 (none missed, controlled several times). And I have my whole database, tables and everything encoded as utf8_general_ci (have tried utf8_unicode_ci and utf8_bin without result). But still I just get the "?-cube" everywhere instead of my swedish letters.

I've made some tests and have come to the conclusion that it's the jquery load and post calls that's responsible for the problem. If i load my php-file "load-folders.php" i get the correct åäöÅÄÖ. But even though the main file "index.php" is saved as AND has enctype utf8 when it calls the jquery load('load-folders.php') i still get the faulty letters. And yes, the jquery.js is also utf-8. So is my stylesheets and everything. I really don't get it. Is there anything else that might cause a problem when using javascript jquery to load a file into another. The standard is supposed to be utf-8 so it should work.

Anyone out the who is able to help me - I love you.

Thanks in advance!

Woobione
  • 3
  • 1
  • Have you tried this? http://stackoverflow.com/questions/553463/jquery-ajax-character-encoding-problem/553572#553572 – fjsj Sep 02 '11 at 01:35
  • Thanks for replying. Yes, I have tried that. It doesn't work :( But why would that even be necessary? I want to use utf-8 all the way. Not encoding it to iso during the load. Thanks anyway :) – Woobione Sep 02 '11 at 01:45
  • Try to encode to utf-8 during the load. – fjsj Sep 02 '11 at 01:54
  • Nope, still doesn't work. Seriously can't understand what's wrong :( – Woobione Sep 02 '11 at 02:06
  • That's a little vague to go on. Basically every single link along the chain source code → database → browser → server → database needs to be told to use UTF-8. Try following this: http://rentzsch.tumblr.com/post/9133498042/howto-use-utf-8-throughout-your-web-stack – deceze Sep 02 '11 at 03:54

1 Answers1

0

I had a problem exactly like this. The only think that worked was:

mysql_query("SET NAMES utf8"); 

Write it just before your mysql query, like this:

mysql_query("SET NAMES utf8"); 
$q = mysql_query("SELECT * FROM ...") or die('Error: ' . mysql_error());

You can read comments over here: http://php.net/manual/en/function.mysql-client-encoding.php

Cristi Pufu
  • 9,002
  • 3
  • 37
  • 43
  • Omg! I have tried that exact thing before without result. But I probably hadn't fixed every other file by then. So this time, IT WORKED!!! Thanks Cristi Pufu! Love you man! :D – Woobione Sep 02 '11 at 11:31
  • [mysql_set_charset()](http://php.net/mysql_set_charset) is the preferred way to this. – str Sep 02 '11 at 12:06