Jump to content

Using htmlentities


dvdflashbacks

Recommended Posts

Does anyone know how I can rewrite this line to include the htmlentites statement?

I am having a problem with some html tags affecting a repeat region on my page and I am trying to remove them with PHP.

<?php echo nl2br(substr($row_rsDisplayFeatures['blog_item'], 0, 1000)) ; ?>

 

thanks.

Link to comment
https://forums.phpfreaks.com/topic/136853-using-htmlentities/
Share on other sites

sorry to butt in im having the same problem on my site, used this code to fix

 

echo substr(htmlentities($row_newsRS['article']),0,700);

 

but all it did was show up the html on the page

 

ie,

<p><span style="font-size:12px;">text here</span></p>

 

which like dvdflashbacks will not want the html to show on the page i also just now tried

echo substr(htmlentities($row_newsRS['article'],ENT_QUOTES,"utf-8"),0,700);

 

but same results??

 

Link to comment
https://forums.phpfreaks.com/topic/136853-using-htmlentities/#findComment-714895
Share on other sites

Try

 

<?php echo nl2br(substr(htmlentities($row_rsDisplayFeatures['blog_item'],ENT_QUOTES,"utf-8"), 0, 1000)) ; ?>

 

Hey waynewax,

 

Well that code worked as it should, but I guess my problem is deeper than this line of code.  It was worth a shot though.

 

Just for background on what I am trying to accomplish:

 

I have a site that has four different repeating regions and recordsets.  Each region display sets of article in different categories.  All of these regions are identical except for the category id and the recordset name for each. 

In one particular region somehow all of the text is being forced into italics or bold and even applying CSS with a font-style of normal is not correcting it. 

 

Now some of these articles do have html tags in them to italics some text or bold other lines.  But I have checked, double checked and triple checked that all the tags are opened and closed properly.  Also it is only this one region that has the problem though all other regions also have records in them with some italic and bold text.

 

The only thing I can determine is that the must be some sort of bad records in that section of the DB.  I was hoping that this line of code  would help on the php side but now the records show the <b></b> tags everywhere that the heading should be bold.  So that won't work either.

 

Thanks again though for showing me how to write this.  It will definitely come in handy somewhere else I am sure.

Link to comment
https://forums.phpfreaks.com/topic/136853-using-htmlentities/#findComment-715298
Share on other sites

use <strong></strong> to bold text <b></b> is the older why which i dont think validates anymore

 

any i asked my question in a different thread and it sorted my problem so try strip_tags()

 

<?php echo nl2br(substr(strip_tags($row_rsDisplayFeatures['blog_item']), 0, 1000)) ; ?>

Link to comment
https://forums.phpfreaks.com/topic/136853-using-htmlentities/#findComment-715301
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.