The issue is what you're passing to against
. Boolean full text search has a specific syntax, and you're passing it things with syntax errors. The error depends on the values you pass in, so it seems "random". MySQL is not being helpful with its no-context error message.
select match (field) against(('123+') in boolean mode) from test;syntax error, unexpected $end
You have to properly escape the value in $derired_word
or use a different fulltext search mode.