1

I am trying to insert records containing Hebrew characters from PHP into a MySQL table.

Both the schema and the table are set with utf8 character set in MySQL. The Web-site is set with a charset=UTF8.

Displaying the query on the web-page renders Hebrew correctly.

However, once inserted into the MySQL table, the Hebrew characters are not stored correctly, rather as gibrish. Example:

×בו סנ×ן

Tried to apply utf8_encode and mb_convert_encoding on the query string - to no avail.

What am I missing? Thanks!

Mor Sagmon
  • 905
  • 1
  • 16
  • 35
  • i hate encoding issues, if nothing works for you, you can base64 encode your strings (if you dont have to compare them against anything, just to store values) – luk2302 Jun 16 '13 at 20:25
  • See [UTF-8 all the way through](http://stackoverflow.com/q/279170) for a comprehensive overview on the issue – Pekka Jun 16 '13 at 20:27

2 Answers2

0

Maybe try:

    $q = mysql_set_charset('utf8');
    var_dump($q);

The var_dump should tell you if the string has been encoded properly before insertion into the database. If it is, the problem lies in the database, if not, the problem lies elsewhere.

0

if you use mysqli try this set_charset("utf8"); directly after new mysqli()

Example:

$db = new mysqli($config['database']['host'], $config['database']['user'], $config['database']['password'], $config['database']['dbname']);
$db->set_charset("utf8");
kevinq
  • 109
  • 1
  • 17