We have a PHP/MySQL application where we are allowing visitors to post a comment. The comment gets held in the database until an admin has "published" it through an online edit form.
I have set up the "submit your comment" form so that the comment field uses the nl2br function to format the inputted text with paragraphs and line breaks.
So looking at the data in the my MySQL database table you can see that it includes the nl2br formatting, namely <br > tags, which is as it should be.
On the other side, we want to allow site admins to edit comments as well as make them available on the site by publishing them.
I am having no trouble echo-ing the visitor's data into the appropriate fields of my "edit this record" form. The problem is that the nl2br-generated <br > tag is included in the comments textarea along with the regular old text data.
How can I get the text to appear in the form's text-area without the <br > tag? I've tried the following but nothing is working:
$comments = ereg_replace('<br >', '', $comments)
$comments = str_replace('<br >', '', $comments)
$comments = htmlspecialcharacters($comments)
$comments = strip_tags($comments)
I'm echo-ing the data like this:
<textarea name="comments" cols="50" rows="8"><?php echo $myrow["comments"]; ?>
</textarea>