Jump to content

Help Inserting HTML into DB


refiking

Recommended Posts

What can I do to insert html into the db?  Is it a setting on my db field or something?  Can't think of anything else it might be.  Here's what I've tried from a programming vantage point:

 

1) addslashes

2) mysql_escape_string

3) mysql_real_escape_string

4) htmlentities

 

All of them provided the same response in the db ultimately. Here is an example entry

<p>
Hey,</p>
<p>
How's it goin?  I've got a couple surefire upset picks for you.  When can we go over them?</p>

Link to comment
Share on other sites

try setting your tables (rows, columns) or more specifically at least where your storing your html to "utf 8 general case insensitive"

 

You can also make your own filters. Where you find key tags in the HTML you want to convert specificly. and do str_replace type of thing on them when they go into the database and store them like bbcode. then when you pull the info out from the database you reverse the technique to covert your new BB code or version there of to change it back to standard HTML

Link to comment
Share on other sites

I figured out something that works (at least for now).  Not sure if this is the best method, but I did addslashes(htmlentities($string)) to insert it, then I did stripslashes(html_entity_decode($string)) to retrieve it.  Hoep that helps someone else :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.