Incorrect search query result

http://php.net/manual/en/function.str-replace.php

mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

$search would be the space " "
$replace would be the percent symbol %
$subject is the original string