It's easier to provide a solution when you provide the code. Otherwise you'll just be given a basic suggestion of creating a conditional region where if something, then something, else something else.
Before executing the SQL search, check that the search string is non-null (and not just spaces). Just check the input string using an IF statement in PHP.
If the string is blank, issue an error instead of the search results.