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
https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/
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.

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.

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.

 

username

CrayonViolent

 

and you do this:

 

select * from table where username='crayonviolent'

 

you will get a result.

 

I didn't know that, nice info. Lucky on my sites i have checked for duplicate usernames on registration.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.