What is wrong with this syntax?
select * from registered_members where username = '$username' AND LIKE '%LOL%'
you need a column name between "AND" & "LIKE"
ie
SELECT * FROM Registered_Members WHERE UserName = '$username' AND UserName LIKE '%LOL%'
select * from registered_members where username = '$username' AND username LIKE '%LOL%'
You're not specifying which column to compare with LIKE
.
"select * from registered_members where username = '" . mysql_real_escape_string($username) . "' and username like '%LOL%'"
Also you need to protect yourself from SQL injection... You should really use parameterized queries.
In addition to adding the column name to search, you should escape the $username
variable to prevent SQL injection: See bobby-tables.com. Otherwise as you have written it, people could execute arbitrary SQL code in your page.