tivrfoa Posted July 29, 2012 Share Posted July 29, 2012 Hi, I'm using PHP and MySQL. It's working fine at my PC (localhost), but it's not on my web hosting. Cordão -> should be Cord?o It's displaying Cord?o at phpMyAdmin. So I checked the collate and character set to see if it's different. They were, so I changed: alter DATABASE db_name CHARACTER SET latin1 COLLATE latin1_swedish_ci; alter table table_name CHARACTER SET latin1 COLLATE latin1_swedish_ci; But this didn't resolved the problem. :'( What else might be the problem? I don't think it's <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> because it's all working fine at my notebook. Regards, Leandro. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/ Share on other sites More sharing options...
tivrfoa Posted July 30, 2012 Author Share Posted July 30, 2012 Hi, So ... when I insert the data through the phpMyAdmin page, it displays correctly in phpMyAdmin but not on the page (where matters). I created a web form to fill the table from there, and then the data displays incorrectly in phpMyAdmin, but correctly in the page! Well. Problem solved I guess. One thing that I'll test is if the collate and character set matters (I changed from utf8 to latin1), or the problem was because I inserted directly using phpMyAdmin. Regards, Leandro. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365338 Share on other sites More sharing options...
jazzman1 Posted July 30, 2012 Share Posted July 30, 2012 Before sending the query string to your database, add this: mysql_query('SET NAMES utf8"); http://forums.mysql.com/read.php?103,22311,249326 Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365340 Share on other sites More sharing options...
Christian F. Posted July 30, 2012 Share Posted July 30, 2012 When working with databases, and especially non-english content, there are 4 places where you need to ensure the right charset: [*]The database table/row, as you noted above. [*]The database connection, as noted by jazzman1. [*]The scripting language features, as you will probably need to use MB-compatible functions for most content. [*]The HTTP headers. Note that only using the meta HTML headers will probably not help, as the HTTP headers override them (if set). That means that if the server is sending out a different HTTP content header, then your meta-equiv is happily ignored by the browser. You'll also want to make sure you're using the same charset in all four places, as mixing charsets is akin to begging for troubles like the one you're experiencing. With no easy way to fix it once it's happened, besides manually fixing every single instance yourself. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365387 Share on other sites More sharing options...
tivrfoa Posted July 30, 2012 Author Share Posted July 30, 2012 Before sending the query string to your database, add this: mysql_query('SET NAMES utf8"); http://forums.mysql.com/read.php?103,22311,249326 Hi, The problem occurs when the data is inserted using phpMyAdmin. This function is not necessary in my script. And this function is not recommended to change the charset. -> http://php.net/manual/en/function.mysql-set-charset.php Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365537 Share on other sites More sharing options...
Christian F. Posted July 31, 2012 Share Posted July 31, 2012 When you use phpMyAdmin you have to make sure that phpMyAdmin uses UTF-8 (normally a choice at the login screen), and send the SET NAMES 'utf8' query before you do anything else. If you keep everything to UTF-8 you'll have the least amount of problems possible. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365565 Share on other sites More sharing options...
tivrfoa Posted July 31, 2012 Author Share Posted July 31, 2012 When you use phpMyAdmin you have to make sure that phpMyAdmin uses UTF-8 (normally a choice at the login screen), and send the SET NAMES 'utf8' query before you do anything else. If you keep everything to UTF-8 you'll have the least amount of problems possible. Hi, I changed everything to utf8_bin: MySQL connection collation, database, table and column. http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html And then I run in phpMyAdmin: set names 'utf8'; update clientes set nome = 'Jos? In?s'; And the problem remains. Only display correctly at phpMyAdmin. I also tested header('Content-type: text/html; charset=utf-8'); but didn't work. http://www.w3.org/International/O-HTTP-charset.en.php For display these data correctly I would need to use utf8_encode everywhere (ouch!!!). It's interesting the number of comments that the page about utf8_encode has: http://php.net/manual/en/function.utf8-encode.php I'll read more, but meanwhile I'll fill the tables using PHP script and not phpMyAdmin. Regards, Leandro. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365580 Share on other sites More sharing options...
tivrfoa Posted July 31, 2012 Author Share Posted July 31, 2012 hmmm it should be: Jos? In edited: it's not displaying correctly here too trying ... & eacute & circ José Inês Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365582 Share on other sites More sharing options...
Christian F. Posted July 31, 2012 Share Posted July 31, 2012 The reason it shows up as "?" now, is because you inserted that data when you had charset issues. All data inserted after cleaning up these issues will be shown correctly, but the data inserted before you'll have to manually correct. Quote Link to comment https://forums.phpfreaks.com/topic/266426-accent-is-ok-when-displaying-in-phpmyadmin-but-not-on-the-page/#findComment-1365667 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.