字符显示正常然后插入带有问号的mysql [重复]

This question already has an answer here:

I'm trying to parse a text file using PHP.

In my database I have data which shows in phpmyadmin like this Triste o melancólico

And once it's retrieved it displays just fine on my website.

Now the issue has come when I try to parse this text file. I will have a word such as Etimología

Now I load the text file, parse it and if I echo the parsed data to the page it will display fine, no question marks / unwanted characters in replace of the í. The thing is if I go to insert the data into my db the special character í is being switched over to a question mark.

I've tried using

mysql_query("SET CHARACTER SET utf8");

After my sql connection but it did not make a difference.

Does anyone have any ideas as to why new text with special characters are being inserted as question marks, when pre existing text with special characters is working just fine?

Thanks

</div>

Try some different set in your mysql database for example utf8_general_ci or utf8_unicode_ci only if utf8_general_ci didn't work :

  1. Log to phpMyAdmin. Select the database from the list on the left.
  2. Click "Operations" from the top set of the tabs.
  3. In the Collation box, choose the new collation from the dropdown menu utf8_general_ci is fine but if you have it already and you still have the problem then try to use utf8_unicode_ci maybe it will solve your problem.
  4. Click Go and see if it solve your problem

Hope this will help you.