I have a string in my database as
in' out"

now i need to show this in input textbox

i did
<input value='in' out"'>
output only: in

<input value="in' out"">
output only: in' out

the real output should be
in' out"

Actually i need to do like this
encode ' => &#039;
and " => &#034;

I m using php serverscript
anyone please help me to encode these quotas

10 Years
Discussion Span
Last Post by naju

to encode it in php...


//encode input going in...
$encode = urlencode("in'out\"");

//decode output coming out...
$decode = urldecode($encode);


If you have to hard code your HTML input tag with that value, then you'll need to write like this:

<input value="'in' out&quot;">

if a user is entering that into a form and posting it to your php script, then simply do this:

//escape quotes from posted variable
$input = addslashes($_POST['value']);

then you can store that value in database. You may need to strip the slashes off when you pull it from the database (depends on MySQL/PHP config)... to do that:

//strip off slashes that were previously added
$output = stripslashes($input);

more on addslashes and stripslashes here


addslashes, stripslashes doesnot fix into my problem.
coz i need to handle the both at once for the value of input tag (which have already an quota itself)
- also saving with addslashes will hamper my Fulltext search.

i wold be cool if .. i could get the quota encoding functions.
as: &quot; for '
or something like that


Thanks bro,

htmlspecialchars solve my problem ..

once again thanks a lot

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.