Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder darksecu's Avatar
    Join Date
    Dec 2011
    Location
    India
    Posts
    109
    Thanks
    11
    Thanked 1 Time in 1 Post

    Using " & ' In Forms Value ?

    i have form input like this
    <input type=text name=code size=50 value="{code}">

    {code} is replaced by value fetched from database.

    My Question Is, Is there any way to use " & ' inside the value="" ?
    when ever it fetch " or ', the result (database value) get broken in parts in input form..

    Thanks In Advance
    Last edited by darksecu; 11-22-2012 at 10:29 AM.
    When You Begin To Practice,That's The Time You Begin To Learn New Things.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    If you are using PHP, you may use function htmlentities() to convert the string before replacing {code}
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder darksecu's Avatar
    Join Date
    Dec 2011
    Location
    India
    Posts
    109
    Thanks
    11
    Thanked 1 Time in 1 Post
    Quote Originally Posted by abduraooft View Post
    If you are using PHP, you may use function htmlentities() to convert the string before replacing {code}


    It didn't work for me..

    PHP Code:
    $str "A 'quote' is <b>bold</b>";

    echo 
    htmlentities($str);
    echo 
    "<br>";
    echo 
    htmlentities($strENT_QUOTES); 
    This is what i got as out put

    A 'quote' is <b>bold</b>
    A 'quote' is <b>bold</b>

    .............

    no change in output...
    When You Begin To Practice,That's The Time You Begin To Learn New Things.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Have you tried
    PHP Code:
    <input type=text name=code size=50 value="<?php echo htmlentities($str);?>">
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder darksecu's Avatar
    Join Date
    Dec 2011
    Location
    India
    Posts
    109
    Thanks
    11
    Thanked 1 Time in 1 Post
    Quote Originally Posted by abduraooft View Post
    Have you tried
    PHP Code:
    <input type=text name=code size=50 value="<?php echo htmlentities($str);?>">
    ?
    It Worked , Now Had Problem In Saving Results. Trying This Now..

    PHP Code:
    // $update = Save Results [convert quotes in variable]
    $update=$_POST[code];
    $update=str_replace("'""%smallquotes%"$update);
    $update=str_replace('"'"%bigquotes%"$update);
    echo 
    "$update <br>";
    // $show = Display Results [convert variable in quotes]
    $show=$update;
    $show=str_replace("\%smallquotes%""'"$show);
    $show=str_replace('\%bigquotes%''"'$show);
    echo 
    "$show <br>"

    Using HTMLENTITILES to save results, working well now
    Last edited by darksecu; 11-21-2012 at 08:43 AM.
    When You Begin To Practice,That's The Time You Begin To Learn New Things.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •