Arkane Posted December 4, 2008 Share Posted December 4, 2008 Hey guys, I'm having issues trying to convert my databases. I currently have a lot of data stored in an xml file which I want to put into a MySQL database. I've written the php fr that, and it works fine, the problem is, that the data is being converted. Many of my fields contain metacharacters, which are being changed when they are entered into the database. Offending things include "Viva Piñata" being changed to "Viva Piñata", and "WALL•E" changing to "WALL•E", along with things such as TM symbols etc This would be fine, except that much of the access to the MySQL uses the actual names, and therefore the garbage-looking characters are just making things screw up. Can anyone tell me why these characters are being converted, and how to stop them being written to the database? cheers Quote Link to comment https://forums.phpfreaks.com/topic/135502-solved-unwanted-string-conversion/ Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 Check these points: 1: Have your database configured as utf-8 2: Have your PHP sources saved as utf-8 3: Have your PHP - MySQL connection utf-8 4: Have your XML file saved as utf-8 (it should be if it's valid XML) Quote Link to comment https://forums.phpfreaks.com/topic/135502-solved-unwanted-string-conversion/#findComment-705920 Share on other sites More sharing options...
Arkane Posted December 4, 2008 Author Share Posted December 4, 2008 OK. well, sorry, but severe newbie here, so not entirely sure how to do all that. :S The database works if "Viva Piñata" is put into it manually, just not if taken from the xml. The xml is saved as UTF8. Other than that, I honestly dont know. Sorry to be so useless Quote Link to comment https://forums.phpfreaks.com/topic/135502-solved-unwanted-string-conversion/#findComment-705936 Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 After you connect php to database, do this query SET NAMES 'utf8' before anything else You have to do this on each connection Quote Link to comment https://forums.phpfreaks.com/topic/135502-solved-unwanted-string-conversion/#findComment-705941 Share on other sites More sharing options...
Arkane Posted December 4, 2008 Author Share Posted December 4, 2008 Thanks very much, yet again, Mchl. That seems to have done it. I've still got some garbage, but I think its mainly from kanji turning into ??? - don't know if thats actually question marks, or the kanji error as an unsupported , but either way, it shouldnt matter too much. thanks very, very much Quote Link to comment https://forums.phpfreaks.com/topic/135502-solved-unwanted-string-conversion/#findComment-705973 Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 Took me two days to figure it out on my own Quote Link to comment https://forums.phpfreaks.com/topic/135502-solved-unwanted-string-conversion/#findComment-705985 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.