Displaying HTML code in textarea. How?

Here's what I've got in my source code:

<textarea name="metatags"><META NAME="DESCRIPTION" CONTENT="RTA Kitchen Cabinets Online, Wholesale Kitchen Cabinets, Buy RTA Cabinets Online, Maple RTA Cabinets"> <META NAME="ABSTRACT" CONTENT="RTA Cabinets, Maple Cabinets, Wholesale Cabinets, Buy Cabinets Online"> <META NAME="KEYWORDS" CONTENT="RTA Cabinet,RTA Kitchen Cabinets, Maple Cabinets, Kitchen Cabinets, buy kitchen cabinets, buy cabinets online, cabinets, rta cabinets, cabinet maker"> </textarea>

This is the result of my doing this:

<textarea name="metatags"><?php echo htmlspecialchars_decode($row['metatags']); ?></textarea>

I'm not seeing anything. My textarea is blank.

What do I need to change?
Bruce GustPHP DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongSoftware Team LeadCommented:
perhaps you can try use some HTML editor instead?

for example, you can try to integrate this HTML editor into your codes:

CK Editor
http://ckeditor.com/
Brian TaoSenior Business Solutions ConsultantCommented:
You're using the opposite of the function. What you need is htmlspecialchars().
Dave BaldwinFixer of ProblemsCommented:
Are you loading this as a *.PHP page or a *.HTML page?  If it's just HTML, the PHP code won't execute.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

srihari chanderSoftware EngineerCommented:
try to change,

<textarea name="metatags"><?php echo htmlspecialchars_decode($row['metatags']); ?></textarea>

to

<textarea name="metatags"><?php echo htmlentities(($row['metatags']); ?></textarea>
Ray PaseurCommented:
Please tell us from a high-level, non-technical perspective: What are you trying to achieve?  The <textarea> is used for HTML input - a place for a client to type information that gets sent to the server.  So this looks very unusual, to be loading a textarea up with things that are normally found in the <head> of the HTML document.  Plus, these are not valid HTML markup, but we can deal with that in another question.  For now, just tell us the objectives and we can probably show you a good way to go about things.
Ray PaseurCommented:
Here is a demonstration script.  Please read the references noted in the comments - they are what you need to understand to pursue the question further.  If you look at the web page, what you see will appear to be the same, but if you use view source, you can see the difference that is hidden by the browser!
http://iconoun.com/demo/temp_brucegust.php
<?php // demo/temp_brucegust.php
/**
 * http://www.experts-exchange.com/questions/28933347/Displaying-HTML-code-in-textarea-How.html
 *
 * References:
 * http://php.net/manual/en/faq.html.php (See #2)
 * http://php.net/manual/en/function.htmlspecialchars.php
 * http://php.net/manual/en/function.htmlspecialchars.php#112476 (Note on UTF-8)
 * http://php.net/manual/en/function.htmlspecialchars-decode.php
 */
error_reporting(E_ALL);

// SIMULATE THE TEST DATA
$row['metatags'] = <<<EOD
<META NAME="DESCRIPTION" CONTENT="RTA Kitchen Cabinets Online, Wholesale Kitchen Cabinets, Buy RTA Cabinets Online, Maple RTA Cabinets"> <META NAME="ABSTRACT" CONTENT="RTA Cabinets, Maple Cabinets, Wholesale Cabinets, Buy Cabinets Online"> <META NAME="KEYWORDS" CONTENT="RTA Cabinet,RTA Kitchen Cabinets, Maple Cabinets, Kitchen Cabinets, buy kitchen cabinets, buy cabinets online, cabinets, rta cabinets, cabinet maker">
EOD;

// SIMULATE THE HTML TEXTAREA(S)
?>
<h2>Clear Text</h2>
<textarea name="metatags"><?php echo $row['metatags']; ?></textarea>

<h2>Using htmlspecialchars()</h2>
<textarea name="metatags"><?php echo htmlspecialchars($row['metatags']); ?></textarea>

<h2>Using htmlspecialchars_decode()</h2>
<textarea name="metatags"><?php echo htmlspecialchars_decode($row['metatags']); ?></textarea>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.