darksecu
11-20-2012, 12:36 PM
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
abduraooft
11-20-2012, 12:53 PM
If you are using PHP, you may use function htmlentities() to convert the string before replacing {code}
darksecu
11-20-2012, 02:45 PM
If you are using PHP, you may use function htmlentities() to convert the string before replacing {code}
:eek:
It didn't work for me..
$str = "A 'quote' is <b>bold</b>";
echo htmlentities($str);
echo "<br>";
echo htmlentities($str, ENT_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...
abduraooft
11-21-2012, 04:45 AM
Have you tried <input type=text name=code size=50 value="<?php echo htmlentities($str);?>"> ?
darksecu
11-21-2012, 08:36 AM
Have you tried <input type=text name=code size=50 value="<?php echo htmlentities($str);?>"> ?
It Worked :), Now Had Problem In Saving Results. Trying This Now..
// $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 :)