Jump to content

HTML ENTITIES DECODE error?


Allenph9

Recommended Posts

So I encode and decode html entities of my thread body variable in my script but now that I am working on the quote function I realize even after decode it prints the html entities instead of the regular character is there anyway to change this because if not it is going to print my font tag as characters instead of the font tag actually doing its job. Thanks! P.S. if this double posts I don't know what's going on...it happened last time but I didn't double post. It may be that I am using a mobile phone.

Link to comment
https://forums.phpfreaks.com/topic/258626-html-entities-decode-error/
Share on other sites

This is on my redirect page...this later writes the value for $reply_body_(post number) in the thread page.

$body1 = strstr ($_POST["reply_body"], '[Quote]');
$body12 = strstr ($_POST["reply_body"], '[/Quote]');
$body13 = str_replace($body12, '', $body1);
$body14 = str_replace('[Quote]', '', $body13);
$body15 = str_replace('[Quote]' . $body14 . '[/Quote]', '<font size="2" color="#66CC00">' . $body14 . '</font>', $_POST["reply_body"]);
$body11 = htmlentities($body15);

 

the thread page has this variable set to this value after putting foobar in quote blocks

 

$thread_reply_7 = '&lt;font size=&quot;2&quot; color=&quot;#66CC00&quot;&gt;foobar&lt;/font&gt;';

 

I then echo the variable inside its respective cell with

 

<?php echo html_entity_decode($thread_reply_7); ?>

\

 

the output on the actual page is...

 

<font size="2" color="#66CC00">foobar</font>

 

in the source code it shows...

 

<font size="2" color="#66CC00">foobar</font>

 

so what gives?

Not really the greatest solution but...

 

$body1 = strstr ($_POST["reply_body"], '[Quote]');
$body12 = strstr ($_POST["reply_body"], '[/Quote]');
$body13 = str_replace($body12, '', $body1);
$body14 = str_replace('[Quote]', '', $body13);
$body15 = str_replace('[Quote]' . $body14 . '[/Quote]', '<font size="2" color="#66CC00">' . $body14 . '</font>', $_POST["reply_body"]);
$body11 = htmlentities($body15);
$body16 = htmlspecialchars($body11 ,ENT_QUOTES);
$body17 = htmlentities('<font size="2" color="#66CC00">');
$body18 = htmlspecialchars($body17 ,ENT_QUOTES);
$body19 = htmlentities('</font>');
$body20 = htmlspecialchars($body19 ,ENT_QUOTES);
$body21 = str_replace ($body18, '<font size="2" color="#66CC00">', $body15);
$body = str_replace ($body20, '</font>', $body21);

 

that works...the only issue is it allows </font> will no longer show up in the reply...and that anyone can type in the exact <font size="2" color="#66CC00"> whatever they want here </font> but that isnt really an issue since you are giving them freedom to do that anyways with the quote block.

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.