Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

getting the text of a textarea (HTML)

dvrslypedvrslype Member Posts: 50
I am making a guestbook, like i told before. My datafile is organised in the way every different piece of data is separated by the newline symbol. Now I also have a textarea, which can contain newlines. I tried the function nl2br() to change those newlines in (br) htmltags, but it doesn't seem to work. So my program thinks the second line of the input of the textarea is a new entry in the guestbook. (Hope I'm making myself clear)

dvrslype

Comments

  • dvrslypedvrslype Member Posts: 50
    : I am making a guestbook, like i told before. My datafile is organised in the way every different piece of data is separated by the newline symbol. Now I also have a textarea, which can contain newlines. I tried the function nl2br() to change those newlines in (br) htmltags, but it doesn't seem to work. So my program thinks the second line of the input of the textarea is a new entry in the guestbook. (Hope I'm making myself clear)
    :
    : dvrslype
    :

    I found this in the PHP manual:
    [hr][italic]
    nl2br

    (PHP 3, PHP 4 )

    nl2br -- Inserts HTML line breaks before all newlines in a string

    Description

    string nl2br ( string string)

    Returns string with '
    ' inserted before all newlines.

    [b]Note: Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions before 4.0.5 will return string with '
    ' inserted before newlines instead of '
    '.[/b][/italic][hr]

    So I assume it's a version conflict. How can I solve that??????


    thx in advance,

    dvrslype
  • SouldrinkerSouldrinker Member Posts: 143
    If we take "$my_textfield" as Name and so as content of the multiline Textbox you use... use the following code to replace every newline-command within that text into some
    Tag:

    $my_textfield = str_replace("
    ", "
    ", $my_textfield);

    have a lot of fun!

    best regards,

    sebastian mohrenstecher
    executive secretary
    net::allies

    www.net-allies.de
    info@net-allies.de

  • Mark StrijbosMark Strijbos Member Posts: 82
    : I am making a guestbook, like i told before. My datafile is organised in the way every different piece of data is separated by the newline symbol

    your datafile is the real culprit here - dont use newlines that way; you have already found out why this is not a good idea. dont use "flat" text files at all but an SQL table. if you need variable length records (as most guestbooks do) use a blob fieldtype like MEDIUMTEXT - it can hold a _lot_ of text but doesnt waste any space it does not need.

    any application stands or falls with the underlying db design - you can save a lot of time, effort and pain during app. development if you take care to design a proper table that is optimised for the job at hand.


  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    ______ ( http://forcoder.org ) free ebooks and video tutorials about < MATLAB C++ C# PHP C PL/SQL Assembly Visual Basic Ruby Go Scratch Visual Basic .NET R Python Objective-C Perl JavaScript Delphi Swift Java Awk SAS Erlang Julia Scheme Logo Rust ML Alice F# LabVIEW Bash Clojure Lisp Dart D Hack VBScript Crystal Lua COBOL Transact-SQL Scala Prolog ABAP Apex Kotlin Fortran FoxPro Ada /> _________

Sign In or Register to comment.