Re: Re: How to escape apostrophe in HTML textbox exactly???

From: Date: Wed, 30 Jun 2004 18:21:19 +0000
Subject: Re: Re: How to escape apostrophe in HTML textbox exactly???
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-189335@lists.php.net to get a copy of this message
This one look and sound good. I'll give this a shot. Thanks a million.... Scott F. "John W. Holmes" <holmes072000@charter.net> wrote in message news:40E2F916.1030909@charter.net... > Red Wingate wrote: > > > use &quot; to display the data in the input-text element and undo this > > before inserting it into the database > > > > function quoteToHtml ( $string ) { > > return str_replace( '"' , '&quot;' , $string ); > > } > > function htmlToQuote ( $string ) { > > return str_replace( '&quot;' , '"' , $string ); > > } > > > > Only way to go :-) > > You don't need to "undo" anything in the data submitted from the form. > This is done automatically. Try it. It's the same as how URL values are > decoded automatically. > > Also, instead of str_replace, you can use > htmlentities($string,ENT_QUOTES), which will convert single and double > quotes (among other characters) just in case you end up using either one > in your HTML. > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#189335) next »