Reputation: 13166
I have a table with some fields. I want to put their contents into HTML inputs.
Everything is ok, but I have just one problem on Textarea.
I want to fill textarea with stored contents. If it has no HTML tags or special characters, the code I have used works fine, otherwise I can not see anything for textarea.
This is my code:
<?php
$query = mysql_query ("SELECT description FROM tblTest");
$returned_content = mysql_result($query,0);
?>
<textarea name="description"><?php echo $returned_content; ?></textarea>
For example if the field contains 123
, I can see this value for textarea. But if it be 123<br />321
I can not see anything.
What's the problem?
Upvotes: 0
Views: 1104
Reputation: 850
Try with this
<textarea name="description"><?php echo html_entity_decode($returned_content); ?></textarea>
Add this between head tags
<meta charset="UTF-8">
Try this also
<textarea name="description"><?php echo htmlentities($returned_content); ?></textarea>
Upvotes: 1
Reputation: 360602
You need to escape the html metacharacters:
<textarea><?php echo htmlspecialchars($returned_content) ?></textarea>
^^^^^^^^^^^^^^^^
Upvotes: 1