echo doesn't render <textarea> wording as it was entered in a form with space between paragrahs, etc.

Posted on 2011-04-26
Last Modified: 2013-12-12
Hello Experts:

I can see new lines in mysql, but when I echo the wording, every line runs together.  

Here's my code:
<div id="copy"><?php echo $row_Recordset1['Copy']; ?></div>

Thank you, help is appreciated.

Question by:comprows
    LVL 18

    Expert Comment

    by:Greg Alexander
    This may do it for you

    <div id="copy"><?php echo nl2br($row_Recordset1['Copy']); ?></div>

    Open in new window


    Author Comment

    That didn't work for me, but that might be because there isn't a \nl in the copy.  There is space between paragraphs though.  You can see it here in the copy shown below from the text area:

    Daily, Weekly or Monthly Specials
    You can enter your special AskNRD promotion in
    this location at any time.

    <a href="../advertising.php">Advertising Info</a>
    LVL 82

    Accepted Solution

    try adding a white-space:pre rule in your css:
    <style type="text/css">
    <div id="copy" style="white-space:pre;"><?php echo htmlentities($row_Recordset1['Copy'], ENT_QUOTES); ?></div>

    Open in new window


    Author Closing Comment

    Thanks to both Experts!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now