mysql_query case questions

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
ZEKI692
Forum Newbie
Posts: 12
Joined: Tue Aug 31, 2010 5:38 pm

mysql_query case questions

Post by ZEKI692 »

Code: Select all

$result = mysql_query(("SELECT * from test WHERE id = '$wanted' OR name = '$wanted'" )) or die('Failed to connect.');
I'm making a search function and I'm trying to configure it so users can search either 'screw' or Screw' and get the same results, but I'm not sure how to change the case. Any help?
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: mysql_query case questions

Post by DigitalMind »

Code: Select all

$result = mysql_query("SELECT * from test WHERE upper(name) = upper('$wanted')") or die('Failed to connect.');
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: mysql_query case questions

Post by Eran »

use a character set that ends in _ci - which stand for case-insensitive
Post Reply