Page 1 of 1

searc difference between Upper and lower strings

Posted: Thu Jan 11, 2007 3:57 pm
by ddragas
Hi all

I'm using following code to create query on mysql db

Code: Select all

$pojam = "some search string";

		$imena_polja_tabela1= array();
		$query1 = "select * from kategorije ";
		$result1 = mysql_query($query1);
		$broj_polja1 = mysql_num_fields($result1);
		
			for ($i1=1; $i1<$broj_polja1; $i1++)
				{
					$imena_polja_tabela1[]= mysql_field_name($result1, $i1);
				}

			foreach($imena_polja_tabela1 as $key1 => $val1)
				{
					$sql_search1 .= $val1 . " LIKE '%$pojam%' or ";
				}
			$sql_search1 = substr($sql_search1, 0, -3);



			$result1 =  "SELECT * from kategorije WHERE (" . $sql_search1 . ")";
and I get difference between Upper and lower strings. Is there a way to avoid this difference?

Thank you

regards ddragas

Posted: Thu Jan 11, 2007 4:06 pm
by Kieran Huggins
case insensitivity? Maybe you could compare the strtoupper() of your variable against a the UPPER()'d column in mysql?

I don't remember if either of these functions exist, and I'm being lazy. But you get my meaning? UPPER both for the comparison.

Posted: Thu Jan 11, 2007 4:32 pm
by feyd
Unless your fields are set with BINARY, MySQL ignores case.