confused about saving html into database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: confused about saving html into database (/showthread.php?tid=60705) |
confused about saving html into database - El Forum - 06-07-2014 [eluser]sessions[/eluser] I have a project that saves html into a mysql database. Usually <pre>, <code> and <p>. Inserting and Updating the db worked fine locally. Once I moved the project to a GD hosted account I get a '406 Not Acceptable' error when I attempt to update or insert content that includes opening or closing html brackets < >: ---------------------------------------------------- Not Acceptable An appropriate representation of the requested resource /index.php/manage/addedit could not be found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. ---------------------------------------------------- If I removed the < and > from content being inserted/updated it works fine. I thought this was an encoding problem. I did find that my local database was set to utf8_unicode_ci whereas the GD live database was set to latin1_swedish_ci. I changed the live db charaset to utf8_unicode_ci but same problem. What other checks should I make to successfully update/insert html brackets ( < > ) into the db? confused about saving html into database - El Forum - 06-07-2014 [eluser]InsiteFX[/eluser] PHP Net htmlentities confused about saving html into database - El Forum - 06-07-2014 [eluser]sessions[/eluser] Same result after changing this: $this->db->set('code', $_POST['code']); to this: $this->db->set('code', htmlentities($_POST['code'], ENT_QUOTES, "UTF-8")); GD support narrowed it down to my code is triggering 'Mod_Security' issue. I tried turning it off with a .htaccess setting but I got more errors. Am I using htmlentities() correctly above? If I am, any other suggestions to get html to insert to my db? Thanks for looking. confused about saving html into database - El Forum - 06-07-2014 [eluser]InsiteFX[/eluser] Sorry it should have been htmlspecialchars. You should use it on your text that you are saving to the database. So if your saving a form textarea that would be the field that you use htmlspecialchars on. If it is already in the database it is in the wrong format, you will need to re-save it. Code: $data = array( confused about saving html into database - El Forum - 06-08-2014 [eluser]sessions[/eluser] Same result. As a test, if I type only '& lt;' in the 'code' textarea I still get the 406. I'm starting to understand that my hosting company has ridiculous security settings that I can't change ( a sacrifice for such a cheap plan ). Thanks for looking though! confused about saving html into database - El Forum - 06-08-2014 [eluser]sessions[/eluser] < confused about saving html into database - El Forum - 06-08-2014 [eluser]InsiteFX[/eluser] This is the hosting company that I use and to me they are one of the best. WebHostingBuzz |