Niixie Posted January 16, 2012 Share Posted January 16, 2012 Hey PHPFreaks! I have some problems with the charset on my site, i don't know if it's the MySQL databases charset or the webpages charset thats wrong, my bet is the database. When i see the text on the page, it loads like this; Dell b�rbar S�lger min Dell, da jeg har k�bt en anden (EDIT: The &#######; is the questionmarks) The questionmarks was supposed to be either 'æ', 'ø', or 'å', but when i write in the PHP document, under the MySQL processed text, it's all fine? How can i change the charset on the MySQL database, so it's alright for special danish characters? Thanks in advance Niixie Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/ Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 If you are using PHPMyAdmin you simply need to change the table/column Collation to something like utf8_general_ci or utf8_unicode_ci Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308267 Share on other sites More sharing options...
Niixie Posted January 16, 2012 Author Share Posted January 16, 2012 I tried them both now, none of them fixes the problem? :s Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308269 Share on other sites More sharing options...
johnny86 Posted January 16, 2012 Share Posted January 16, 2012 ALTER DATABASE xxxx CHARACTER SET utf8 COLLATE utf8_danish_ci; Should get you on utf-8.. Now you do have to make sure that all your files are also utf-8 and you send the proper headers for the browser telling you prefer utf-8.. Remember to define charset at your html head with meta tag.. When you get input, check the content-type header also to make sure the browser is sending utf-8 back. Some browsers won't tell you the type but then you just have to rely on the right behavior. If you're getting wrong charset; use iconv to convert the data to utf-8. You need to know what you're converting and the only way to know it is if the browser tells you what charset it is sending... All and all that's the basics of making sure you always have the right charset. Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308270 Share on other sites More sharing options...
Niixie Posted January 16, 2012 Author Share Posted January 16, 2012 I set all tables in the database to utf8_danish_ci, manually, still nothing. I have this in all the pages that has the <head> tags; <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Nothings wrong there, as i can see? Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308271 Share on other sites More sharing options...
johnny86 Posted January 16, 2012 Share Posted January 16, 2012 Nothings wrong, are you sure you have saved your files as utf-8? The data in your database won't be converted as you change your database charset.. You need to insert it again or update. Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308277 Share on other sites More sharing options...
Niixie Posted January 16, 2012 Author Share Posted January 16, 2012 i ran this code UPDATE `itrades` SET `shortdis`="æøå" WHERE `tradeid` = 2; but still the same errors? Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308296 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 Are you getting the data straight from the database, or are you putting it through sanitation functions and such? Quote Link to comment https://forums.phpfreaks.com/topic/255153-somethings-wrong-with-my-charset/#findComment-1308318 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.