How do I make my textinput accept apostrophe or double quotes?
Everytime a user type's in this one: John's Birthday, I store this one in the database using mysql_real_escape_string().
What I wanted to do in here is to retrieve it in my text input. I tried this one
<input type='text' name='title' value='<?php echo $values->title; ?>' />
The problem here is it removes the single quote and the letters that es after the quote.
I tried to changed the value= ''
from value=""
but what if a user types a word that has example this one:
"You and Me". The problem is still in there.
I was thinking to use str_replace in doing this one and replace the ' into `, but again I was thinking that maybe there's an easy way to do it.
Any help would be greatly appreciated.
Thanks!
How do I make my textinput accept apostrophe or double quotes?
Everytime a user type's in this one: John's Birthday, I store this one in the database using mysql_real_escape_string().
What I wanted to do in here is to retrieve it in my text input. I tried this one
<input type='text' name='title' value='<?php echo $values->title; ?>' />
The problem here is it removes the single quote and the letters that es after the quote.
I tried to changed the value= ''
from value=""
but what if a user types a word that has example this one:
"You and Me". The problem is still in there.
I was thinking to use str_replace in doing this one and replace the ' into `, but again I was thinking that maybe there's an easy way to do it.
Any help would be greatly appreciated.
Thanks!
Share Improve this question asked Sep 29, 2011 at 1:16 PinoyStackOverflowerPinoyStackOverflower 5,30218 gold badges66 silver badges134 bronze badges 1- 3 Duplicate of stackoverflow./questions/1771798/… – nnnnnn Commented Sep 29, 2011 at 1:21
3 Answers
Reset to default 4Check out this: http://www.primitivetype./articles/quotes_inputs.php
Basically, call htmlentities
on your output before placing it in the form's value. This will turn characters like '
into the html equivalent '
.
e.g.
<input ... value='<?php echo htmlentities($values->title, ENT_QUOTES); ?>' />
You can replace double quotes with "
. '
for single quotes.
Replace single quote with ‘