Need help with a simple problem!

Discussion in 'PHP' started by Crayz, Feb 8, 2007.

  1. #1
    <INPUT type=hidden value="<? echo $var2; echo $var2;?><br><br>" name="body"></FORM>
    Code (markup):
    The variable, $var2 , contains html which uses the " tags and is closing the data area for the value tag and executing the rest of the html early, and I can't change the " s to ' inside my html code because it will not work then.

    Any suggestions?

    Thanks.
     
    Crayz, Feb 8, 2007 IP
  2. ErectADirectory

    ErectADirectory Guest

    Messages:
    656
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <INPUT type=hidden value="<? echo $var2 . htmlentities($var2);?><br><br>" name="body"></FORM>

    or

    <INPUT type=hidden value='<? echo $var2 . $var2 ;?><br><br>' name='body'></FORM>
     
    ErectADirectory, Feb 8, 2007 IP
  3. technoguy

    technoguy Notable Member

    Messages:
    4,369
    Likes Received:
    306
    Best Answers:
    0
    Trophy Points:
    205
    #3
    Try this

    echo '<INPUT type=hidden value='.$var2.$var2.' name=body>';
    PHP:
     
    technoguy, Feb 8, 2007 IP
  4. Crayz

    Crayz Well-Known Member

    Messages:
    708
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    120
    #4
    htmlentities seems to distort my html code a bit, turning some quotes into a box with uot after it. Other then that, it works perfect.

    Is there any solution to this?
    thanks
     
    Crayz, Feb 8, 2007 IP
  5. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #5
    try addslashes() around the one with html, failing that, do str_replace('"', "'", $var2 )
     
    krakjoe, Feb 9, 2007 IP