Is there anyway to do a case insensitive query. I tried to use a LIKE '%$text$%' statment but it didn't work. I tried to change the field from varchar to text but it didn't make any difference.
the LIKE clause IS case-insensitive
and it should be
LIKE '%$text%'
not
LIKE '%$text$%' // notice you have extra dollar sign
Sorry typo it's 1.00am.
The one I tried to use was
$result=mysql( "$DBName", "SELECT Username from Login where strtolower(Username) LIKE '$%Username%'"); Any ideas?
either way you do it LIKE is not case sensitive, this is straight from mysql.com
By default, MySQL searches are case-insensitive (although there are some character sets that are never case-insensitive, such as czech). That means that if you search with col_name LIKE 'a%', you will get all column values that start with A or a. If you want to make this search case-sensitive, use something like INSTR(col_name, "A")=1 to check a prefix. Or use STRCMP(col_name, "A") = 0 if the column value must be exactly "A".
from the page
http://www.mysql.com/doc/en/Case_sensitivity.html
Thanks for that. Now a big ask. Every LIKE statement I try to use either ends up in an error or doesn't do a proper search. Has anyone got a simple search with a like statement involved?
$query = "select * from tablename where fieldname LIKE '%$variablename%";"; $result = mysql_query($query) or die(mysql_error());