Search code examples
phpzend-frameworkcharacter-encodingzend-dbmultibyte

Character missing when saving a row?


$userTb = new My_Tb_User();  //Child of Zend_Db_Table_Abstract
$row = $userTb->find(9)->current();
$row->name = 'STÖVER';
$row->save();

Inside user table at row 9 for name column value ST gets stored instead of STÖVER ?

Ö is a german character supported in UTF-8 . IF I enter manually 'STÖVER' using phpmyadmin it get stored correctly .

I also passed charset parameter with value utf8 when creating db adapter but still no luck !


Solution

  • This is a bad practice to use utf8_encode, this adds a lot of complexity to your app. Try to solve the problem by looking for the source.

    Ssome thoughts :

    • a database server charset problem (check encoding of your server)
    • a database client charset problem (check encoding of your connection)
    • a database table charset problem (check encoding of your table)
    • a php default encoding problem (check default_encoding parameter in parameters.ini)
    • a multibyte missconfigured (see mb_string parameters in parameters.ini)
    • a <form> charset problem (check that it is sent as utf-8)
    • a <html> charset problem (where no enctype is set in your html file)
    • a Content-encoding: problem (where the wrong encoding is sent by Apache).