#1
  1. No Profile Picture
    newmediaarts
    Guest
    Devshed Newbie (0 - 499 posts)
    I'm working with a mysql/php setup and have run into a major problem (for me atleast). We have mysql TEXT fields that contain line breaks and the kind something like

    FIELD CONTENT
    -------------
    First paragraph

    Second paragraph

    Third Paragraph
    --------------
    END FIELD CONTENT

    While that is fine in MySQL when it is output to HTML it comes out as

    NETSCAPE
    ---------
    First paragraphSecond paragraphThird paragraph
    ---------
    END NETSCAPE

    Does anyone know of a php function that can add in the needed <BR> and <P> so that the output will actually look as intended?

    ------------------
    Luke Bowerman
    new media arts
    www.judebowerman.com/nma

  2. #2
  3. No Profile Picture
    newmediaarts
    Guest
    Devshed Newbie (0 - 499 posts)
    Never mind... I made my own solution using a build in function & a regular expression.

    $var = stripslashes($var);
    $var = ereg_replace( "n","<br>",$var);

    ------------------
    Luke Bowerman
    new media arts
    www.judebowerman.com/nma

  4. #3
  5. No Profile Picture
    ExPulse
    Guest
    Devshed Newbie (0 - 499 posts)
    PHP has a built in function nl2br();

    http://www.php.net/manual/function.nl2br.php3

    It is faster than using regex.

Similar Threads

  1. How to get client email??Help plz
    By Gecko22 in forum ASP Programming
    Replies: 12
    Last Post: January 22nd, 2004, 01:40 PM
  2. Build HTML tables with multiple mySQL queries
    By SailFan in forum PHP Development
    Replies: 5
    Last Post: January 19th, 2004, 11:25 AM
  3. not returning records when it should
    By aliaga61 in forum ASP Programming
    Replies: 3
    Last Post: January 16th, 2004, 10:57 AM
  4. Help!!! Updating MySQL Record using HTML Form
    By kashaf in forum PHP Development
    Replies: 2
    Last Post: January 16th, 2004, 09:32 AM
  5. 'Object required' error
    By aliaga61 in forum ASP Programming
    Replies: 1
    Last Post: January 16th, 2004, 08:48 AM

IMN logo majestic logo threadwatch logo seochat tools logo