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

From: Date: Wed, 30 Jun 2004 17:26:52 +0000
Subject: Re: Re: How to escape apostrophe in HTML textbox exactly???
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189319@lists.php.net to get a copy of this message
On Wed, 30 Jun 2004 19:32:29 +0200, Red Wingate <redeye@erisx.de> 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 ); > } Much better to use htmlentities(), it will get all quotes and other special chars (<, >, etc) which can cause problems. > function htmlToQuote ( $string ) { > return str_replace( '&quot;' , '"' , $string ); > } > You don't need to do this. When the browser submits the request, it will come through $_REQUEST as a quote, not as an HTML entity. > Only way to go :-) > > Scott Fletcher 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-- > > > > I can't use the HTML feature like &quot or something because the > > "&quot" > > would show up in the database... Any suggestion or advice? > > > > Thanks, > > Scott F. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > !DSPAM:40e2f52755689422721120! > > -- paperCrane --Justin Patrin--

« previous php.general (#189319) next »