Im using the following PHP and MySql to fetch rows from a table,
$search_word=$_GET['search_word'];
$search_word_new=mysql_escape_string($search_word);
$search_word_fix=str_replace(" ","%",$search_word_new);
$sql=mysql_query("SELECT * FROM tweets WHERE content LIKE '%$search_word_fix%' ORDER BY votes DESC LIMIT 20");
The ‘content’ field is a TEXT field containing tweets.
The problem I have is if I search ‘Stackoverflow’ I get all the results containing ‘Stackoverflow’ but no results when the text is ‘stackoverflow’. Basically the search is case sensitive.
Is it possible to change the query or PHP so when searching for ‘Stackoverflow’ both upper and lower case results are returned?
You can try:
strtolowerto make$search_word_fixall lower case.contenttolower(content)so thatI compare with lowercase of
content.You could have made both these changes in the query as suggested in other answer.