Page 1 of 1

Password case sensitivity

Posted: Sat Nov 09, 2002 10:14 am
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...

Posted: Sat Nov 09, 2002 12:10 pm
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: