The reason you are getting everything back is because of a silly little $ in your query.
$sql_statement = "SELECT * FROM configurations WHERE memory LIKE '%3%' OR '%$4%' ";
The last part should be '%4%' not '%$4%'.
The $4 makes php think of a variable, which since there is no $4 variable, it puts in nothing in place of $4, so you get '%%' which is the same as saying
Give me all fields from the table configurations where memory contains a 4, or memory contains any character at all, including no character.
Dave