Stupid question sprintf ()

How to add SQL wildcard characters to this:

 sprintf("SELECT robot FROM robots WHERE robot LIKE '%s'",strtolower($user_agent));

as

 sprintf("SELECT robot FROM robots WHERE robot LIKE '%%s%'",strtolower($user_agent));

explodes into an exciting ball of flame

PS sorry for the pretty simple question. These days I cut back on coffee.

+3
source share
1 answer

The literal %is specified as %%, so you want"... LIKE '%%%s%%'"

+15
source

All Articles