Jump to content

HTML is messing up


prolife
Go to solution Solved by dungpt29,

Recommended Posts

Hi guys i typed and saved som text from my admin page, i tried displaying it in my home page but it has some html a nd some styles inlcuded, please how do i convert it to plain text, i already used htmlspecialchars and htmlentities , i noticed some.changes but what i want to is a plain text.

 

This is what it gave me when i viewed it with "htmlspecialchars"

<font face="Times New Roman"><b><font size="5">You Are welcomevv</font></b></font>

 

and here is the code i used in displaying-:

 

echo htmlspecialchars($object->data['page-body']) ;

 

Please i need your help.

 

Thanks.

Edited by prolife
Link to comment
Share on other sites

htmlspecialchars does what the name suggests, it converts HTML control characters (<, >, ', ") into their HTML4 entities... which are generally universally supported if you display them.

But, as requinix hinted above, why would you escape HTML control characters if you actually want to use HTML?

Oh, by the way, <font> is deprecated. Don't use it.

Link to comment
Share on other sites

Guys, you dont seem to understand. Let me break it down. I have an Admin pannel where i can edit certain pages on my site, now my admin pannel has a text editor which enables me to make my text bold, change clolour etc.So saving a bold text for instance will look something like this<strong> My text </strong>. Now my question is how do i display this formated text so that it reatains the alteratio; bold for instance without displaying the HTML.

Thanks!

Link to comment
Share on other sites

  • Solution

Hi prolife,

I guess that you are trying to save the formatted text from a text editor into your database. Then you want to display it on your webpage as plain text.

You should try the following PHP function and it worked for me:

<?php echo html_entity_decode("data pulled out from database")?>
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.