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
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?

Link to comment
Share on other sites

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.

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.