realjumper Posted June 18, 2006 Share Posted June 18, 2006 Hi,I cannot seem to display any Japanese text that comes from the db. The pgae encoding is correct - shitf jis - and any hard coded text displays just fine. I have tried all manner of collation combinations for the db and the tables, but nothing seems to work. the results displayed range from a seies of question marks...????????....to some sort of 2 byte characters being displayed, but not the correct ones. From what I have been able to find out via google, both the table and the db collations should be utf8_general_ci, which doesn't work. I have tried many other combinations of ujis etc etc, but nothing seems to return the correct charaters to the web page. This was previously working well on older versions of php and mysql, but since the update to the '5' versions I have been in this jam. If anyone can help I would apprecitate it very much.Thanks,Neil Quote Link to comment https://forums.phpfreaks.com/topic/12335-php-5-mysql-5-display-problem/ Share on other sites More sharing options...
realjumper Posted June 19, 2006 Author Share Posted June 19, 2006 *bump*Anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/12335-php-5-mysql-5-display-problem/#findComment-47460 Share on other sites More sharing options...
realjumper Posted June 20, 2006 Author Share Posted June 20, 2006 Here is the answer:The database was and is set up like so:Collation - utf8_unicode_ciThe tables were and are set up like so:Collation - utf8_general_ciThe html page encoding was and is set up like so:....content=text/html; charset=sjisThe problem was that hard coded Japanese would render correctly in the browser, but anything retrieved from the db came back as ??????. If I changed the encoding on the page to 'utf8' or 'default', the hard coded Japanese would become unreadable, but the db would return the correct Japanese record.If, through my html page, I inserted data in the db, the inserted data was just a jumble of characters BUT a select query would return the correct Japanese record. So, the hard coded Japanese AND the data from the table rendered correctly, BUT the data was unreadable via PhpMyAdmin.....so that was not satisfactory.However, by adding.....mysql_query("SET CHARACTER SET sjis"); immediatlely below my connection string, the problem went away and everything is just perfect.....yipee!!Just why PHP5 and/or Mysql5 require this I don't know, and I guess no one here does either as I recieved no responses to my question.So anyway, if anyone is interested, if the tables and the db collation is set as I have described above, AND mysql_query("SET CHARACTER SET sjis"); is put right under your connection string, you should be fine. Of course if you want to add a different character set to the string you could replace sjis with utf8 or whatever.Hope this helps somebody Quote Link to comment https://forums.phpfreaks.com/topic/12335-php-5-mysql-5-display-problem/#findComment-47521 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.