RE: [PHP] striping unwanted characters from $string

From: Date: Mon, 19 May 2003 16:28:07 +0000
Subject: RE: [PHP] striping unwanted characters from $string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148182@lists.php.net to get a copy of this message
> I have a problem in that if a user inputs a string with ' in it the > dynamically generated links will not work, as they read the ' as the end > of > the string (yeah?) > > I have read the manual regarding htmlspecialchars, stripcslashes, > htmlentities, stristr and so on....but I find it all very confusing - > which > am I supposed to use? and are there other characters that could cause a > similar thing? Sounds like you need urlencode(), actually. If you have something like this: <a href='link.php?var=$var'>Link</a> and $var has a ' in it, it'll break like you're saying. So use urlencode() on $var before you insert it into the link. Decoding is automatic on the next page, so you do not have to worry about that. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#148182) next »