vicodin Posted November 26, 2008 Share Posted November 26, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/ Share on other sites More sharing options...
DeanWhitehouse Posted November 26, 2008 Share Posted November 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699110 Share on other sites More sharing options...
Maq Posted November 26, 2008 Share Posted November 26, 2008 Store it as they typed it in. Display it by grabbing it straight from the DB. When comparing use was blade said, strtolower or strtoupper, your preference. Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699111 Share on other sites More sharing options...
vicodin Posted November 26, 2008 Author Share Posted November 26, 2008 Got it... Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699115 Share on other sites More sharing options...
EchoFool Posted November 26, 2008 Share Posted November 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699117 Share on other sites More sharing options...
DeanWhitehouse Posted November 26, 2008 Share Posted November 26, 2008 I would say it is best to keep the username as it is that way you can have variety's of the same username. Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699120 Share on other sites More sharing options...
.josh Posted November 26, 2008 Share Posted November 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699124 Share on other sites More sharing options...
DeanWhitehouse Posted November 26, 2008 Share Posted November 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/134290-mysql-reconize-upper-and-lower-case/#findComment-699125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.