[PHP] Adding html inside SQL database? [FIXED]
is there a way to put html code inside an SQL table and then load it to the page via php and display it like html within the page?
Like how myspace lets you add html or CSS for optimizing your page.
If not, would I be able to easily do it with a text/folder database & PHP?
(I'd have to redo the whole thing if I do this :S)
EDIT: I figured it out, I just needed to use htmlentities() and html_decode_entity() and it worked.
Re: [SQL] Adding html inside SQL?
just add slashes...
then remove slashes when u get it from sql.
Re: [SQL] Adding html inside SQL?
Quote:
Originally Posted by
john_d
just add slashes...
then remove slashes when u get it from sql.
How is that supposed to work? It didn't do anything..
Am I supposed to make the SQL row/colum something other then type:TEXT?
If so, what?
Does htmlentities do it? I'm looking that up.
EDIT: I found it :D! the fix was this:
before sending to the database do this:
PHP Code:
$newaboutMe=htmlentities($aboutMe);
When getting from the database, do this:
PHP Code:
$aboutMe=html_entity_decode($aboutMe);
Re: [PHP] Adding html inside SQL database? [FIXED]
You only have to escape the quotes, so addslashes should be sufficient...
Re: [PHP] Adding html inside SQL database? [FIXED]
Re: [PHP] Adding html inside SQL database? [FIXED]
Quote:
Originally Posted by
Daevius
You only have to escape the quotes, so addslashes should be sufficient...
Well when I try to submit raw HTML to my SQL database, the < and > tags are stripped. I have to convert them to < and > with htmlentities($string) and decode them after their loaded with html_entity_decode($string) before I display them on the page. I got it all working already so it doesn't matter.
But when I tried addslashes() all it did was conserve the quotes and everything was kind of messed up..
Maybe my SQL database preferences are wierd or something.. But I got it working so it's all good.
and for ^above^ - I already got it working, but yes, that would've worked too since it's basicly the same as the html entity scripts