GeorgeFive Posted November 12, 2008 Share Posted November 12, 2008 Hey there, I'm sure this has come up countless times over, but I'm coming up empty in searches. How do you "quote-proof" a string when doing a search like... $query = "SELECT arow WHERE MATCH (arow) AGAINST ('".$phrase."' IN BOOLEAN MODE)" '".$phrase."' is the key part there - it should be able to contain parenthesis (') and quotes ("), but it's sort of a one or the other deal.... 'this isn't going to work' Opening and closing with the parenthesis errors out because of the parenthesis inside, so change that to... "this isn't "going" to work" and we now get an error because of the quote inside with opening/closing quotes. I know about htmlentities and addslashes, but neither of these will work - I need zero slashes / htmlentities inside the query for the query to work. $query = "SELECT arow WHERE MATCH (arow) AGAINST ('quote"quote' IN BOOLEAN MODE)" will not work, but $query = "SELECT arow WHERE MATCH (arow) AGAINST ('quote"quote' IN BOOLEAN MODE)" will, and similarly, $query = "SELECT arow WHERE MATCH (arow) AGAINST ("par\'par" IN BOOLEAN MODE)" will not work, but $query = "SELECT arow WHERE MATCH (arow) AGAINST ("par'par" IN BOOLEAN MODE)" will. I hope this makes sense...? Link to comment https://forums.phpfreaks.com/topic/132487-solved-using-quotes-with-boolean-search/ Share on other sites More sharing options...
genericnumber1 Posted November 12, 2008 Share Posted November 12, 2008 You can call the database to find the proper way to escape quotes with mysql_real_escape_string() if that's what you mean.... Link to comment https://forums.phpfreaks.com/topic/132487-solved-using-quotes-with-boolean-search/#findComment-688944 Share on other sites More sharing options...
GeorgeFive Posted November 12, 2008 Author Share Posted November 12, 2008 I figured out a nice little way to do it... $phrase = str_replace("'", "'", $phrase); That did the trick for me. Link to comment https://forums.phpfreaks.com/topic/132487-solved-using-quotes-with-boolean-search/#findComment-688969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.