SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with uppercase and lowercase.....

    Hi,

    Im having problems with comparing data that has a capital letter at the front.

    In my MySQL database there is a username Admin, and when someone trys to make a new user with the name of admin it will let them and the check will fail, so there will be two people with the same usernames.....

    Is there a simple way to make this code pick up that the usernames are the same?

    PHP Code:
    $sql "SELECT name FROM schools WHERE name = '".$_POST['schoolname']."' LIMIT 1";
    $res mysql_query($sql) or die(mysql_error());
        
    if (
    mysql_num_rows($res) > 0) {
        
    $name_check mysql_result($res00);
    }else{
        
    //Not found
    }

    if (
    $name_check == $_POST['schoolname']) {
        
    $_SESSION['error'] = "takenname";
        die(
    header ("location: main.php?page=error"));

    Any ideas??

    Thanks,
    Raining
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Afternoon Raining,
    PHP Code:
    $var_lc strtolower($_POST['schoolname']);
    $var_orig $_POST['schoolname'];

    $sql "SELECT name FROM schools WHERE name = '".$var_lc."' or name = '"$var_orig ."' LIMIT 1"
    $res mysql_query($sql) or die(mysql_error()); 
         
    if (
    mysql_num_rows($res) > 0) { 
        
    $name_check mysql_result($res00); 
    }else{ 
        
    //Not found 


    if (
    $name_check == $_POST['schoolname']) { 
        
    $_SESSION['error'] = "takenname"
        die(
    header ("location: main.php?page=error")); 

    Not pretty but it should work.

    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Long time no see Spike , thanks for the help.

    That is how I thought I could do it, but I wasent sure if there was a more simple way. The only problem I will have now, is that I could end up with someone called Admins, and someone else called aDmins lol.

    Thanks,
    Raining
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    The way around that is to stop the casing when the user signs up or use a LiKE in the query.

    PHP Code:
    $sql "SELECT name FROM schools WHERE name LIKE '".$var_lc."' or name LIKE '"$var_orig ."' LIMIT 1"
    $res mysql_query($sql) or die(mysql_error()); 
    That might leade to a few 'fluffy' results though as its less accurate but it might help!

    Mike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •