View Full Version : html tags getting printed in <textarea>

07-14-2008, 07:50 AM
Hi all,
i am trying to display the address of the user in a textarea. (using PHPAJAX). i am already displaying the default address in the <textarea> and it works perfect with all breaks and nbsp;'s. But there is an option for the user to change it. i am using PHPAJAX to let the user select the id's from the list and display the address mapped to that ID is displayed in <textarea>.
the problem is now its displaying the address as below

Mr. ABC&amp;lt;br&amp;gt;POLAND

i tried using all possible options like htmlentities() , htmlspecialchars(), nl2br() but all is falling.

below is my code:

function main() {
$Relation_ID = & $this->Relation_ID;

global $db;
if ($Relation_ID!="") {

$Address =(htmlentities(GetRelAddress($Relation_ID)));
aprint ('RelationInfo' , htmlentities($Address));
} // end

what should i do?


07-14-2008, 08:53 AM
Hi, you need to decode the values instead of encoding them. Look into htmlspecialchars_decode (http://ca3.php.net/manual/en/function.htmlspecialchars-decode.php) and html_entity_decode (http://ca3.php.net/manual/en/function.html-entity-decode.php)

Hope that helps!

07-14-2008, 09:14 AM
that isnt helping too. still the same

Hope i get some help on it

07-14-2008, 10:12 AM
What is the code for GetRelAddress, aprint and alert? If the aprint or alert are also using htmlentities or htmlspecialchars you won't get the correct decoding on the given string. Check into those three functions and see if any of them make use of the same.

07-14-2008, 02:46 PM
Hello Fou-Lu,

MILLION THANKS TO YOU. you were right!!!! i was already using the htmlentities() in GetRelAddress(). Now i am directly using it and it works PERFECT