$test = sprintf(\"SELECT * FROM `table` WHERE `text` LIKE \'%%s%\'\", mysql_real_escape_string(\'test\')); echo $test;
output:
SELECT
You need to escape the percent signs with a percent sign %%.
%%
$test = sprintf("SELECT * FROM `table` WHERE `text` LIKE '%%%s%%'", mysql_real_escape_string('test')); echo $test;