I am using following query:
$search = mysql_query("SELECT * FROM `users` WHERE username LIKE '%".mysql_real_escape_string($query)."%' OR name LIKE '%".mysql_real_escape_string($query)."%' ORDER BY timestamp");
where $query is words user search for. I am getting following warning:
Warning: mysql_real_escape_string() expects parameter 1 to be string
The table has username as varchar. Is this what problem is? Or can anyone please help me if they know what is causing this warning?
$query(the VARIABLE) is no string. That’s the simple answer that the error message already told you.Fix that. Listen to what the error message says. It doesn’t speak about the query itself, but the /variable/.