using text area to store and retrieve values...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pushpinderbagga
    New Member
    • Sep 2007
    • 10

    using text area to store and retrieve values...

    hi ..
    I am using a text area to feed in values to mysql ..
    but its not storing all the line breaks
    the text comes concatenated
    even when I feed it about 40 lines... it shows all in one line ...
    do i need to use something ... like stripslashes or nlbr something .. but whre....
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Pushpinderbagga .

    Show us some code so that we can get a better sense of the context. You might be better off storing the data in the _SESSION....

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      When you do a carriage return when tying data in your textbox the Crs will be returned to you when you get the textbox content.
      However, when you continue typing in your textbox but let the width of the textbox make a wrap, the wrap is NOT translated into a CR or a LF.

      So, are you sure you use hard CRs in your text input?

      Ronald

      Comment

      • pushpinderbagga
        New Member
        • Sep 2007
        • 10

        #4
        Here is the code... Please have a look ...

        [CODE=php]

        $jokeText = $_GET['jokeText'];

        $query1 = "INSERT INTO joke (`joketext`) VALUES ('".$jokeText." ')";

        [/CODE]

        this is working but the carriage new lines or the cariage returns arnt showing when I display it in the page like

        [CODE=php]

        $row['joketext'];

        [/CODE]


        it simple as in this text area in which I am posting ...
        the carriage returns are preserved ...
        do i need to do something like

        [CODE=php]

        $jokeText = $_GET['jokeText'];

        $jokeText = trim($jokeText );
        $jokeText = stripslashes($j okeText );
        $jokeText = htmlspecialchar s($jokeText )

        and then insert ... and when displayig .. just

        nl2br($jokeText )

        is it .... please help .. me confused...

        $query1 = "INSERT INTO joke (`joketext`) VALUES ('".$jokeText." ')";

        [/CODE]

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Pushpinderbagga .

          What do you want your code to do? Give an example.
          What is your code doing that you don't want it to do? Give an example.
          What is your code *not* doing that it is supposed to? Give an example.

          Comment

          • pushpinderbagga
            New Member
            • Sep 2007
            • 10

            #6
            Just take the example of a simple guestbook. If user enters some text and then presses the ENTER key 10 times thus introducing 10 line breaks and enters more text then..
            while displaying i need to keep those entered newlines preserved or you may say intact..

            Comment

            • robbiesmith79
              New Member
              • Oct 2007
              • 4

              #7
              Ok.

              Rule #1 when submitting forms with textarea's. Use <form method="POST">

              method="GET" does not retain carriage returns i.e. 40 lines in textarea's.

              Comment

              • pushpinderbagga
                New Member
                • Sep 2007
                • 10

                #8
                thanks
                even I thoought of this ...bt never triued implementing it ... thanks again will ... try and revert ..

                Comment

                Working...