-
Hello!
I just started learning PHP and MySQL about a week ago, so this is probably a stupid question :rolleyes:, but anyway...
I am using this code:
Code:
$Result = mysql_query("SELECT UserName, Password, LastLogin FROM Members WHERE UserName = '" . $username . "'");
and it works, but when somebody enters their username and it doesn't have the same case as when they registered (say, websurfer907 instead of Websurfer907) it won't work. UserName is a varchar, and every MySQL site I've seen says that varchar is case-insesitive. What am I doing wrong? I also tried this:
Code:
$Result = mysql_query("SELECT UserName, Password, LastLogin FROM Members WHERE STRCMP('" . $username . "', UserName) = 0");
and the same thing happened. Help!
-
http://www.php.net/manual/html/function.strtolower.html
try doing this
Code:
$Result = mysql_query("SELECT UserName, Password, LastLogin FROM Members WHERE strtolower(UserName) = '" . strtolower($username) . "'");
I am not absolutely sure if strtolower will work with UserName (not a PHP variable, it's a mysql variable.. or whatever)
just try it!!! :p :rolleyes:
-
It didn't work. It gave me this error:
Warning: 0 is not a MySQL result index in /usr/home/progstuf/login.php on line 31
any other ideas? maybe there is a MySQL version of strtolower?
-
-
What the....
It didn't work for some reason... this is what I tried:
Code:
$Result = mysql_query("SELECT UserName, Password, LastLogin FROM Members WHERE LCASE(UserName) = '" . strtolower($username) . "'");
Any ideas?
-
Never mind.
I got it to work. I had some code further down that checked if the usernames were the same again but it didn't use strtolower. Oops. :rolleyes: