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
ddragas
Forum Contributor
Posts: 445 Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas » Thu Jan 11, 2007 3:57 pm
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
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Thu Jan 11, 2007 4:06 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 11, 2007 4:32 pm
Unless your fields are set with BINARY, MySQL ignores case.