You should stick with %%%s%% since %% means % when used in sprintf, and %s is the string placeholder.
However, if you have
sprintf('%s .... %s', 'string');
... then you get "too few arguments", since you have two placeholders, requiring two string parameters, and you only provide one (mysql_real_escape_string($_GET['q'])).
So, either (one per %s)
mysql_real_escape_string($_GET['q']),
mysql_real_escape_string($_GET['q']),
mysql_real_escape_string($_GET['q']));
Or change your %%%s%% into %%%1$s%%, since they will then all reference the first placeholder parameter.