Results 1 to 6 of 6

Thread: PHP/MySQL question...

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    10
    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!

  2. #2
    Guest
    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!!!

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    10

    Unhappy

    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?

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    10

    Smile

    Ah ha! Found it.

    http://www.mysql.com/documentation/m...ce.html#IDX734

    Going to try it now

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    10

    Question 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?

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    10
    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
  •  



Click Here to Expand Forum to Full Width