[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 " 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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php