Allenph9 Posted March 10, 2012 Share Posted March 10, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258626-html-entities-decode-error/ Share on other sites More sharing options...
trq Posted March 10, 2012 Share Posted March 10, 2012 Post your code. Quote Link to comment https://forums.phpfreaks.com/topic/258626-html-entities-decode-error/#findComment-1325743 Share on other sites More sharing options...
Allenph9 Posted March 10, 2012 Author Share Posted March 10, 2012 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 = '<font size="2" color="#66CC00">foobar</font>'; 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? Quote Link to comment https://forums.phpfreaks.com/topic/258626-html-entities-decode-error/#findComment-1325748 Share on other sites More sharing options...
Allenph9 Posted March 10, 2012 Author Share Posted March 10, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258626-html-entities-decode-error/#findComment-1325756 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.