-1

Can someone help me with this. The form needs to make no difference between capital letters and normal letters.

$raw_results = mysql_query("SELECT * FROM product
            WHERE (`naam` LIKE '%".$query."%') OR (`titel` LIKE '%".$query."%') OR (`druk` LIKE '%".$query."%')") or die(mysql_error());

The charset is latin1_bin

Koessien
  • 1
  • 4

4 Answers4

1

You could use UPPER in mysql.

$raw_results = mysql_query("SELECT * FROM product
            WHERE (UPPER(naam) LIKE UPPER('%".$query."%')) OR (UPPER(titel) LIKE UPPER('%".$query."%')) OR (UPPER(druk) LIKE UPPER('%".$query."%'))") or die(mysql_error());
JTC
  • 3,344
  • 3
  • 28
  • 46
  • Invalid use `LIKE '%".UPPER($query)."%'` or your fixed one `LIKE '%UPPER(".$query.")%'`. Function should be outside of the string `LIKE UPPER('%".$query."%')`. – Glavić Sep 19 '13 at 10:44
  • Thanks and sorry about that. – JTC Sep 19 '13 at 10:48
  • Can to answer this question.. https://stackoverflow.com/q/56066980/11065582 –  May 10 '19 at 03:19
1

That depends of collation that you're using for your field. With default latin1_general_ci collation (or similar _ci-ended) comparison and string functions will be insensitive to case.

So, you have two options. First - use strtolower() in your PHP application or LOWER() in MySQL itself - to convert your search strings to lower case (i.e. make them independent of their original content case). Second - use the corresponding collation for fields containing your data. More information than I've already provided - is in case sensitivity manual page.

Alma Do
  • 37,009
  • 9
  • 76
  • 105
0

Make use of strtolower to Lowercase all your query and then do the search.

Something like this so it will match all.

$query=strtolower($query);
$raw_results = mysql_query("SELECT * FROM product
            WHERE (`naam` LIKE '%".$query."%') OR (`titel` LIKE '%".$query."%') OR (`druk` LIKE '%".$query."%')") or die(mysql_error());
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
-3

convert all into either lowercase or upper case it will work

$raw_results = mysql_query("SELECT * FROM product
            WHERE (strtolower(naam) LIKE '%".strtolower($query)."%') OR (strtolower(titel) LIKE '%".strtolower($query)."%') OR (strtolower(druk) LIKE '%".strtolower($query)."%')") or die(mysql_error());
Janak Prajapati
  • 896
  • 1
  • 9
  • 36