quotes problem

Discussion in 'PHP' started by stats, Oct 8, 2007.

  1. #1
    i'm getting conflict between my HTML and PHP code because of quotes. Here's the situation


    1-st page has an HTML code like this

    echo "<input name='mytext' type='text'>"

    then it passes the value to the next page via a POST

    2-nd page has this code :

    echo "<input name='mytext' type='text' value=' " . $_POST['mytext'] ." '>"

    now , if the text is like Carl's Name Is Carol, then here's what i see in the source of the second page in my browser

    <input name='mytext' type='text' value='Carol\'s Name Is Carol'>

    so then it passes on the value as only Carol\

    what do i do with this ?

    Thanks
     
    stats, Oct 8, 2007 IP
  2. madura99

    madura99 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can use quotes in otherway around
    try this

    echo '<input name="mytext" type="text">' ;

    echo '<input name="mytext" type="text" value=" ' . $_POST['mytext'] .'">';

    all the best
     
    madura99, Oct 8, 2007 IP
  3. stats

    stats Well-Known Member

    Messages:
    586
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #3
    that will lead to the same situation if someone type something like

    Press the "Search" button

    i mean .. there should be a universal solution to all quotation problems rather than a "try to fix somehow" solution.. so i'm looking to find that solution
     
    stats, Oct 8, 2007 IP
  4. stats

    stats Well-Known Member

    Messages:
    586
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #4
    something tells me that i need here those "magic_quotes_gpc" things .. but i have no any idea of what they do and how to use them
     
    stats, Oct 8, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    nico_swd, Oct 9, 2007 IP
  6. stats

    stats Well-Known Member

    Messages:
    586
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #6
    You're as useful as always :)

    htmlspecialchars is what i need :)

    Thanks!


     
    stats, Oct 9, 2007 IP