Jump to content

MYSQL reconize Upper and Lower Case


vicodin

Recommended Posts

Hello all, lets say i have some users and when they made their account the made the username: John Doe. now they go to sign in and they type in john doe instead of John Doe. Will MYSQL see it the same either way? If not how can i make it so MYSQL will get it the same everytime but i also want their name to be to show up on the site the same way they made it when they registered?

Link to comment
Share on other sites

No it won't, if it did it wouldn't be very sage.

You can't without changing everyone's, also this will limit the amount of usernames available.

 

But if you really want to what you should do is use strtolower(); or strtoupper(); or ucfirst(); and adjust the username on registration before inserting into the database or when reading it from the database and then perform the same on the username entered when logging in.

Link to comment
Share on other sites

I simply just set to fields for this issue:

 

login field and display field

 

the login field would be all lowercase so JoHn DoE would become john dowe and will always work. The display field maintains the capital letters that the user first used which you use to echo their username on the site.

Link to comment
Share on other sites

I think he's saying his problem is for instance if the user registers as CrayonViolent but tries to login as crayonviolent he can't strtolower etc... until after the query, obviously.  So he needs a way of doing a case insensitive query.  Fortunately for you, mr. vicodin, non-binary strings (char, varchar and text data types) use the collation of the comparison operand you use.  And fortunately for you, mr. vicodin, by default, string comparisons are not case sensitive and use the current character set. 

 

In other words, if you have:

 

username

CrayonViolent

 

and you do this:

 

select * from table where username='crayonviolent'

 

you will get a result.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.