in reply to PERL and MySQL

I think your culprit is here:
WHERE `Keys`.`Keywords` LIKE '%$search%'
sprintf is trying to interpret the % characters as format string tokens. If the first character of $search is a valid field specifier, you get weird results. You want literal % characters in the finished expression, so use '%%' instead:
WHERE `Keys`.`Keywords` LIKE '%%$search%%'
...and I bet things might go your way.

Proof of concept:

bash$ perl -e '$a=22; printf "%$a%\n";' % bash$ perl -e '$a=22; printf "%%$a%%\n";' %22%