Re: How to escape apostrophe in HTML textbox exactly???
| From: | Scott Fletcher | Date: | Wed, 30 Jun 2004 19:36:36 +0000 |
| Subject: | Re: How to escape apostrophe in HTML textbox exactly??? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189348@lists.php.net to get a copy of this message | ||
In one of the reply to the original posting I made, someone say that
htmlentities() would work and upon submission, the PHP's $_REQUEST, $_POST,
$_GET would get the apostrophe somehow. (The conversion somewhere would
change it back)....
"Chris Shiflett" <shiflett@php.net> wrote in message
news:20040630185722.23779.qmail@web52803.mail.yahoo.com...
> --- 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/