On Sun, Nov 23, 2008 at 4:44 PM, Moshe Teutsch <[EMAIL PROTECTED]> wrote:
> I'm having a problem INSERTing Hebrew text into a MySQL database. > Whenever I try to do it through my PHP application the fields that contain > Hebrew text end up blank. The collation for the Hebrew fields is > *utf8_general_ci. > *I have very little experience with Hebrew in PHP and MySQL applications, > and would really appreciate any help. > > The real question is: Does PHP, indeed, insert Hebrew when you think it does? To avoid problems, the character set must be coherent along all stages; 1. The table needs to be UTF-8. 2. The connection with the DB needs to be UTF-8 (it is preferred to have this set as default in my.cnf). 3. PHP must send UTF-8 data in the MySQL query: If the text you enter is hardcoded inside the PHP code, then the PHP file, as you edit it in your text editor, must be saved with the UTF-8 encoding. If the data comes from an external application that talks to PHP and submits data via GET/POST, then it must do so in UTF-8 as well. And finally, if your text comes from a web form that the user enters, the web page that contains the web form itself, must be UTF-8, so the browser sends the data as UTF-8. The latter is the most well-known "trouble maker" for the problem you're facing; It is easily solved by adding the meta tag: <meta http-equiv='Content-type' content="text/html; charset=utf-8" />. Also make sure that your web server does not force a different encoding via HTTP headers; Apache started doing it at some version in the past, with the AddDefaultCharset directive. HTH, -- Shimi