CodeIgniter Forums
Storing HTML in DB - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Storing HTML in DB (/thread-15307.html)

Storing HTML in DB - El Forum - 01-31-2009

I need to store html code (full page) in my database, but I'm having trouble when inserting it. If I insert the page with phpMyAdmin it works perfectly (I store it in a TEXT data type, just copy-pasting the code), but when I use CodeIgniter (ActiveRecord insert with the code coming from a form textarea) it will mess it up quite a bit. It transforms some characters to html entities, which I understand is escaping for security reasons, not a big problem. The big problem is that, from a 34300 character html file, only 7291 characters are stored (and this includes the "new" html entities, which take up more characters than the original). Where is the lost data going? Any ideas? Is there a better way to store html code?

Storing HTML in DB - El Forum - 02-02-2009

Ok, I figured out what was causing the problem, but I have no idea why... In my HTML file I have "% caracteristicas%" (without the quotes and without the space), which is a custom tag I use to later substitute a list of characteristics. For some reason, that exact combination makes CodeIgniter or PHP or MySQL freak out. If I change it to $caracteristicas$ it won't be a problem... very weird. Anyway, I just used the $ version and it works so, I don't mind. Just in case anybody is interested.

p.s. I just saw in the preview that the combination "% ca" (without the space) doesn't work here either (spits out an undefined character: �), wonder what it means...

Storing HTML in DB - El Forum - 02-02-2009

Did you try escaping the characters? This might help.

Storing HTML in DB - El Forum - 02-13-2009

How do you escape HTML data? I've tried

$this->db->escape($string) but this isn't working.