briant Posted January 16, 2008 Share Posted January 16, 2008 Alright, I don't know why all of a sudden inserting special characters into the DB isn't working. Maybe because I just changed host or different mysql version or something. php ver: 5.2.5 mysql ver: 5.0.37 Well, I tried doing a simple insert. It inserts regular characters and pass but when it comes to French/Viet characters ie: âơù, it will come back with an error. $sql = "INSERT INTO site SET name = 'Thùy'"; I've also tried changing the Collation from latin1_swedish_ci to utf8_bin but that didn't work. Any help please? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/ Share on other sites More sharing options...
Wuhtzu Posted January 16, 2008 Share Posted January 16, 2008 May we please have the error? Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441194 Share on other sites More sharing options...
briant Posted January 16, 2008 Author Share Posted January 16, 2008 Basicly I added this error: if (!mysql_query($sql)) die("ERROR"); Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441197 Share on other sites More sharing options...
revraz Posted January 16, 2008 Share Posted January 16, 2008 if (!mysql_query($sql)) die("ERROR" .mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441199 Share on other sites More sharing options...
briant Posted January 16, 2008 Author Share Posted January 16, 2008 Oh thanks, here is the error: Incorrect string value: '\xF9y Tra...' for column 'name' at row 1 Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441202 Share on other sites More sharing options...
revraz Posted January 16, 2008 Share Posted January 16, 2008 Do you get a UTF-16 option? Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441207 Share on other sites More sharing options...
briant Posted January 16, 2008 Author Share Posted January 16, 2008 Nope, only UTF-8. I don't think it has anything to do with the collation since it worked before with latin1_swedish_ci. Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441212 Share on other sites More sharing options...
crashmaster Posted January 16, 2008 Share Posted January 16, 2008 try: to find special chars of Swedish alphabet in UTF-8 table... for example: ý = ý And than use string replace, to prevent it Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441217 Share on other sites More sharing options...
revraz Posted January 16, 2008 Share Posted January 16, 2008 Not sure if this helps When you create the table, set session collation_database=latin1_swedish_ci; set session character_set_database=latin1; Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441219 Share on other sites More sharing options...
briant Posted January 16, 2008 Author Share Posted January 16, 2008 Oh I'm sorry guys. Thanks for all the support. It was a template problem that didn't support special characters. Nothing related to mysql. Works well now, sorry, and thanks again for the help. Quote Link to comment https://forums.phpfreaks.com/topic/86343-solved-inserting-special-characters-to-mysql-with-php/#findComment-441223 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.