I’m trying to save some values from a form in CakePHP into a MySQL database and when the values go into the database they are getting html encoded.
So something like (#45) gets stored in the database as (#45) and then when someone tries to go back and edit the form they see all the extra characters.
I’ve tried setting the encoding on the database connection to utf8 like this:
private $production = array(
'driver' => 'mysql',
'persistent' => true,
'host' => 'localhost:3306',
'login' => '',
'password' => '',
'database' => 'db',
'prefix' => '',
'encoding' => 'utf8'
);
and have this set in my configuration:
Configure::write('App.encoding', 'UTF-8');
and also added this to my default layout:
echo $html->charset();
Any Ideas?
I found where the encoding was happening. In the AppModel class it was calling Sanitize::clean without ‘encode’ set to false
Once I set encode to false for the clean method it worked correctly