Update replace.php

Add check if search string is in object.
Rewrite query syntax to correct SQL syntax.