Andy252 Posted January 18, 2007 Share Posted January 18, 2007 How do I remove any " ' and ` from a string ? Link to comment https://forums.phpfreaks.com/topic/34793-remove-chars/ Share on other sites More sharing options...
dgiberson Posted January 18, 2007 Share Posted January 18, 2007 You could do a string replace... Is this so the data will insert into a db? if so you can just do $var = addslashes($var); and it will insert no problem Link to comment https://forums.phpfreaks.com/topic/34793-remove-chars/#findComment-163991 Share on other sites More sharing options...
Andy252 Posted January 18, 2007 Author Share Posted January 18, 2007 I have that in place at the moment.Its for putting URLs into MySQL. The problem is if someone put " ' ` in the URL is cocks up the scripting when it prints out the URL on the front end. Link to comment https://forums.phpfreaks.com/topic/34793-remove-chars/#findComment-163993 Share on other sites More sharing options...
Andy252 Posted January 18, 2007 Author Share Posted January 18, 2007 Also could do with removing < > too.Thanks Link to comment https://forums.phpfreaks.com/topic/34793-remove-chars/#findComment-163998 Share on other sites More sharing options...
boo_lolly Posted January 18, 2007 Share Posted January 18, 2007 [quote author=Andy252 link=topic=123046.msg508124#msg508124 date=1169155371]How do I remove any " ' and ` from a string ?[/quote][url=http://us3.php.net/manual/en/ref.strings.php]string manual[/url]that should get you goin. Link to comment https://forums.phpfreaks.com/topic/34793-remove-chars/#findComment-164008 Share on other sites More sharing options...
Hypnos Posted January 18, 2007 Share Posted January 18, 2007 [code=php:0]$badchars = array("\"", "'", "`", "<", ">");$cleanstring = str_replace($badchars, "", $dirtystring);[/code]You could also do this with a regular expression and preg_replace. Link to comment https://forums.phpfreaks.com/topic/34793-remove-chars/#findComment-164037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.