searc difference between Upper and lower strings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

searc difference between Upper and lower strings

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Unless your fields are set with BINARY, MySQL ignores case.
Post Reply