0

I know this question has been asked a million times before, but I'm unable to find a solution to this specific issue.

I'm saving the word "Tečný" from my PHP 5.6 application to a MySQL 5.6 db, using PDO::prepare() and PDOStatement::execute(); The data being passed in is definitely correct. The DB connection is made using 'SET NAMES utf8'. and 'SET CHARACTER SET utf8'.

When the string reaches the db, it's saved as "Te?ný". However, when I save it manually with MySQL Workbench, it saves and retrieves correctly.

Am I missing something?

  • 1
    Thank you @your-common-sense. Your links helped me to find that I needed to run `ALTER DATABASE db_name_here CHARACTER SET utf8 COLLATE utf8_general_ci;` - this has solved the issue. – codeandchips Apr 25 '17 at 15:34
  • No. Changing the `DATABASE` _defaults_ will not change any existing table _defaults_, much less any existing column settings. – Rick James Apr 28 '17 at 20:52
  • I'm not saying it changed the table or column settings. I'm saying this is the change I needed to successfully add utf8 characters to the db. This was the single change I needed, as everything else was setup properly. – codeandchips May 01 '17 at 08:50
  • You also need `charset=utf8` in the `new PDO(...)`. – Rick James May 01 '17 at 17:29
  • Yip, I had everything else I needed, just what I listed was all I was missing. Thanks Rick James. "Cocaine is a hell of a drug!" – codeandchips May 03 '17 at 11:39

0 Answers0