SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Jersey
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    small parse (well not quite) error

    im echoing the contents of a field into a textarea to be edited. my code looks like this....

    PHP Code:
    ........ value=" '; echo $row["data"]; echo ' "> ......... 
    i also tried
    PHP Code:
    ........ value=\" ' . $row["data"] . ' \"> ......... 
    only problem both add a "> to the end of the data field from the database everytime it updates. anyone know how i can fix it?
    Matt Daly

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Arizona, USA
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would it be impractical to post all of the code? I can't really figure out what's happening based on that small snippet..


    TIA

  3. #3
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Jersey
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the code runs fine. its inside a while statement that selects form the database etc. then a form on the page contains the database entries for editing

    PHP Code:
    <textarea class=\"post\"  name=\"data\" rows=\"6\" cols=\"30\" value=" ' . $row["data"] . ' \"> 
    (the class="post\" is class=\"post\" it just for some reason won't show the first \ above)

    all code above and below is simply just a normal html form with a few echos for the database entries. and the appropriate php entries.

    i was thinking of doing a string replace on $data. but the entry within the textarea has html code in which has lots of ">'s in it
    Matt Daly

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Arizona, USA
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by matt-daly
    all code above and below is simply just a normal html form with a few echos for the database entries. and the appropriate php entries.
    I got that, but from the limited amount of code posted I still can't discern what's causing the additional "> to be tagged to the end of your posted data. If I had to take a guess, I'd say it had something to do with the way you're echoing the <textarea> tag (there is "> at the end there), but without the entire block to look at, it would only be a guess..

  5. #5
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by matt-daly
    PHP Code:
    <textarea class=\"post\" name=\"data\" rows=\"6\" cols=\"30\" value=" ' . $row["data"] . ' \"> 
    A textarea should look like this:

    HTML Code:
    <textarea name="data">
       Some text inside a text area
       </textarea>
    Not like this:

    HTML Code:
    <textarea name="data" value="This text will never show up" />
    You may want to try validating your HTML output at some point so that you can fix these invalid HTML problems more easily... see:

    http://validator.w3.org/

    hth,
    Douglas
    Hello World

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    HTML Code:
    <textarea name="data" value="This text will never show up" />
    Rofl.. :P I was going to say that.. just have the variable in between the <textarea>'s :P

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Arizona, USA
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Nothing like overlooking the obvious...

  8. #8
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BittenApple
    Rofl.. :P I was going to say that.. just have the variable in between the <textarea>'s :P
    That's the problem you get when you have people trying to learn PHP when they don't even know basic HTML...

    Douglas
    Hello World

  9. #9
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    so the code should read
    Code:
    <textarea class="post"  name="data" rows="6" cols="30" value=" <? echo $row["data"]; ?> ">
    Just so you know!
    BTW if you are escaping " make sure you do them all!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •