Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[PHP] Adding html inside SQL database? [FIXED]

Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
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.
 
Last edited:
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
Re: [SQL] Adding html inside SQL?

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:
$newaboutMe=htmlentities($aboutMe);

When getting from the database, do this:
PHP:
$aboutMe=html_entity_decode($aboutMe);
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Jun 28, 2007
Messages
2,986
Reaction score
3
You only have to escape the quotes, so addslashes should be sufficient...
 
Skilled Illusionist
Joined
May 23, 2007
Messages
345
Reaction score
0
Try using


 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
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
 
Back
Top