• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Storing HTML in DB

#1
[eluser]chillbill7[/eluser]
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?
Thanks!

#2
[eluser]chillbill7[/eluser]
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...

#3
[eluser]the_namdeeW[/eluser]
Did you try escaping the characters? This might help.

#4
[eluser]gh0st[/eluser]
How do you escape HTML data? I've tried

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.