0

I had a problems with insertions in mysql.

I have a script in PHP which get a string from a external file with "accents" and "ñ" and a database in myslq with a table in collation utf8_spanish_ci, and the "accents" and "ñ" was inserting in DB with problems.

When was debugging my strings arrive to the insert code line perfectly ("María","Toño", ...) whit accents and everything correct and after insert characters mysql truncate all strings until first strange character arrive (accent or ñ). Trying to solve the problem i changed collation from table and fields by latin_swidish_ci ¡and the problem change! the insertion was replacing "accents" an "ñ" by "?" anything strange by "?". After Hours fighting with that ¡the answer!, using uft8_code() function from PHP, I converted all the correct strings to a strings with a lot of strange characters, and Mysql change this characters by "accents" and "ñ" inserting correct datas.

Why did happend?, Why Mysql accept strange characters and change that by the correct?

  • Make sure your database is UTF-8 compatible. http://stackoverflow.com/questions/202205/how-to-make-mysql-handle-utf-8-properly – Guillaume Renoult Jun 25 '15 at 01:14
  • Did you set the character set? Is your PHP page in UTF8? http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – chris85 Jun 25 '15 at 01:37

0 Answers0