|
-
Oct 21st, 2000, 02:48 PM
#1
Thread Starter
New Member
Hello!
I just started learning PHP and MySQL about a week ago, so this is probably a stupid question , 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!
-
Oct 21st, 2000, 03:17 PM
#2
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!!! 
-
Oct 21st, 2000, 03:27 PM
#3
Thread Starter
New Member
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?
-
Oct 21st, 2000, 03:31 PM
#4
Thread Starter
New Member
-
Oct 21st, 2000, 03:35 PM
#5
Thread Starter
New Member
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?
-
Oct 21st, 2000, 03:42 PM
#6
Thread Starter
New Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|