Re: String display issue

From: Date: Tue, 25 Nov 2003 03:02:50 +0000
Subject: Re: String display issue
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170840@lists.php.net to get a copy of this message
Jay Blanchard wrote:
[snip] I am writing an application where users will input information such as 6' section of 3/4" pipe How can I get the whole line to show up on the screen when both single and double quotes are contained in the text string. [/snip] addslashes going in stripslashes coming out http://www.php.net/addslashes
1. For the original question, I assume you mean when putting data like that _back_ into a form element? <input type="text" name="product" value="<?php echo htmlentities($product); ?>"> The key is htmlentities() will convert double quotes to &quot; but it'll still show up as a " character within the text box. If you want it to do both single and double quotes, then use htmlentities($yourVar,ENT_QUOTES); 2. As for the addslashes() remark, note that you _do not_ have to use strip_slashes() when pulling data back out of a database (unless you have magic_quotes_runtime enabled). If you're finding that you do need to use stripslashes, i.e. you actually see "That\'s It" in your database, then you're running addslashes() twice. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#170840) next »