Jump to content

[SOLVED] Using quotes with boolean search


GeorgeFive

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.