0

how to insert utf-8 format in database with latin collation and table with utf8 collation?!

I want to insert to some of wordpress database tables from my own php file , but it's not working, if I change the databsae collation into utf8_general_ci it's working , I don't want to change the database collation , wordpress it self working with that and it doesn't have any problem, سلام -> ؟؟؟؟

Samad
  • 1,776
  • 2
  • 20
  • 35

1 Answers1

0

You can try

$mysqli->set_charset("utf8");

before you do any inserts.

Michel
  • 4,076
  • 4
  • 34
  • 52
  • is mysql_query("SET NAMES utf8"); doing the same?! – Samad Oct 17 '14 at 13:42
  • It's the same, but somehow `SET NAMES` is not recommended. From the manual: This is the preferred way to change the charset. Using mysqli_query to set it (such as SET NAMES utf8) is not recommended. See the MySQL character set concepts section for more information. – Michel Oct 17 '14 at 13:49