SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formatting.. line breaks

    Curious - (I'm certain this has been brought up a billion times, but maybe I was searching for the wrong key words.) - but whats the deal with sql not outputting the format used on input?

    i.e. line breaks.. the enter key.

    Fill out a form with say,

    "hi

    whats up?

    ok then!"

    outputs as

    "hi whats up? ok then!"

    Thanks in advance for any input on this

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hiya!

    Try the nl2br() function!

    http://uk2.php.net/nl2br

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply

    Ok I tried:

    Code:
    <? echo n12br("$note"); ?>
    and I'm getting this: "Fatal error: Call to undefined function: n12br() in /home/virtual/site200/fst/var/www/html/phases78/forums/admin/admin.php on line 291"

    Hmm.

  4. #4
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this!
    PHP Code:

    $newnote 
    nl2br("$note");
    echo 
    $newnote

  5. #5
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you're using the number one instead of lowercase L.

    n12br <--- uses #1 (wrong)
    nl2br <--- uses lower case L (correct)

    it's new line 2 br

  6. #6
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL!!!!! never even noticed that!! Sorry... I should have made more clear. I think its just the way the 'L' appears in the code block!

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You the man, you know that? The man!

    Thanks

    How come it had to be done that way? can't have a function in an echo?

  8. #8
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think you can.....well.....you must not be able to anyway!

    Good Job! You were using a L then!!! LOL

  9. #9
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was using a 1, but then I just copy/pasted what you told me to try. lol

    Thanks guys

  10. #10
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can echo a function, it just has to exist.

  11. #11
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep. Redid it the original way I tried with a l instead of a 1. Works great

  12. #12
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL!!! ah well....its sorted now

  13. #13
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    New question..

    What about this: When someone uses an apostrophe, or quotes, it messes everything up.

    How do I get around that? I want people to be able to use special characters here..

  14. #14
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In addition to nl2br use this function on the text as well htmlspecialchars

    If that's not the problem more details are needed.


Bookmarks

Posting Permissions

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