richardjh Posted March 25, 2008 Share Posted March 25, 2008 I have a simple script which searches the site on a given keyword. The keyword from the form is sent to the script via 'GET' thus: $keyword = $_GET['keyword']; the script simply queries the database for terms thus : %keyword% All seems to work fine apart from if the entered keyword contains an appostrophie. So if I entered: O'Neill into the search box (I know this term exists), the url looks like this: http://mysite.com/search.php?keyword=O%27Neill&choose=person ...and the script can't find a match. If I enter just Neill (without the O' ) then it finds it fine. I've tried str_replace. how can I approach this? thanks R Link to comment https://forums.phpfreaks.com/topic/97715-search-terms-in-url/ Share on other sites More sharing options...
MadTechie Posted March 25, 2008 Share Posted March 25, 2008 $keyword = addslashes($_GET['keyword']); or better still $keyword = mysql_escape_string($_GET['keyword']); Link to comment https://forums.phpfreaks.com/topic/97715-search-terms-in-url/#findComment-499998 Share on other sites More sharing options...
richardjh Posted March 25, 2008 Author Share Posted March 25, 2008 Hmmmmm Something seems to be working a bit better using your suggestion MadTechie. I just need to strip the slashes from the returned and echoed keyword and that should do the trick. many thanks for the fast and accurate reply. R Link to comment https://forums.phpfreaks.com/topic/97715-search-terms-in-url/#findComment-500024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.