Results 1 to 4 of 4

Thread: mysql question

  1. #1
    Junior Member
    Join Date
    Aug 2001
    Posts
    17

    mysql question

    Need help...

    I have stored a formatted text content of three paragraphs long into a field of type TEXT.

    When I retrieve the text content from the MySQL database using a PHP script and have it displayed on a HTML, I get a continuous text instead of three paragraphs of text.

    Any ideas on how I can display the text properly? Thanks.

  2. #2
    Senior Member roswell1329's Avatar
    Join Date
    Jan 2002
    Posts
    670
    Yup. MySQL doesn't care what a carriage return is. The way I got around that is I used PHP to search for the carriage return character (I think it was '\n', or perhaps '\r\n') and replaced it with a
    HTML Code:
    
    
    tag. There is probably a cleaner way to do this, but this method worked for me. Good luck, and let me know what you use.
    /* You are not expected to understand this. */

  3. #3
    Senior Member roswell1329's Avatar
    Join Date
    Jan 2002
    Posts
    670
    Found the PHP code I used to search for carriage returns in a string and replace them with
    or

    tag:

    PHP Code:
    $mystring preg_replace("/\r\n|\n\r|\n|\r/""
    "
    $mystring); 
    Hope that works for you
    /* You are not expected to understand this. */

  4. #4
    Junior Member
    Join Date
    Aug 2001
    Posts
    17

    Smile thanks roswell1329

    Thanks for the help, will check it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •