In the function search_autocomplete_autocomplete you build the query with sprintf() and pass it through db_query(). Everthings fine as long als the suggestion query and the search keyword don't build a new %-modifier.
For example:

Query: "SELECT .... n.title LIKE '%%%s%%'"
Keyword: batman
After sprintf it looks like this: "SELECT .... n.title LIKE '%batman%'"

In phpmyadmin everythings fine but db_query tries to replace '%b' with a binary and the query don't return any suggestion. To fix this, just replace:

$suggestions  = db_query($query);

with:

$suggestions  = db_query($item['sug_query'], $word);

Comments

dom.’s picture

Hi!

Sorry I did not reply ealier, I was in holiday! I will be back home by tomorrow and have a look at it.

Since the beginning, I was unhappy with the numerous %%% in the query string. Therefore, I will make a reliease with your change.

Even maybe better, I would like to avoid the %%% (and the %-modifier issue I did not though about). To do so, I will probably change the query with something like:
SELECT ... LIKE #
As the symbol # should not be use in DB query, I will be able to change
#
by
"%" . $word . "%"
without using any sprintf like function.

Miro

dom.’s picture

Status: Active » Fixed

Ported in 6.x-2.2

Thanks a lot for reporting and for fix suggestion !
Miro

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.