Re: How to escape apostrophe in HTML textbox exactly???
| From: | Chris Shiflett | Date: | Wed, 30 Jun 2004 18:57:22 +0000 |
| Subject: | Re: How to escape apostrophe in HTML textbox exactly??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189341@lists.php.net to get a copy of this message | ||
--- Scott Fletcher <scott@abcoa.com> wrote:
> I'm using data that goes from the HTML textbox to PHP to MYSQL to
> PHP to HTML textbox. The only trouble I have is to escape the
> apostrophe character when it is put into the HTML textbox by PHP
> (from MySQL).
>
> --snip--
> echo "<input type='textbox'
> value='".$value."'>";
> --snip--
You could quote your attributes like I do:
<input type="text" value="foo" />
Then apostrophes won't be a problem. :-)
The better answer is to use HTML entities. There's a nice function called
htmlentities() that can help with this.
> I can't use the HTML feature like " or something because the
> """ would show up in the database... Any suggestion or advice?
As they say, timing is everything.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming Fall 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/