Password case sensitivity

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
allanw
Forum Newbie
Posts: 1
Joined: Sat Nov 09, 2002 10:14 am

Password case sensitivity

Post by allanw »

Helou!

This MySQL query:

Code: Select all

SELECT * FROM tablename WHERE username='$UserName' AND password = '$PassWord'
...returns a row even if passwords are case inCoRrEcT.

I know PHP strings are case sensitive, but:

Is there a way to alter the query above to only return a row if the passwords match case sensitively?

In this case, passwords are not supposed to be encrypted. Don't ask why...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://www.mysql.com/doc/en/Case_Sensitivity_Operators.html
6.3.2.2 Case-Sensitivity
BINARY
The BINARY operator casts the string following it to a binary string. This is an easy way to force a column comparison to be case-sensitive even if the column isn't defined as BINARY or BLOB:
Post Reply