MySQL-output is case-sensitive?
Moderator: General Moderators
MySQL-output is case-sensitive?
Hello!
Atm. im building a new website with a adminpanel and of course a login-system. But when i enter the username it's in case-sensivity, which i dont want. Eg. "Lureren" works because that is how its entered in the database, while "lureren" doesnt work?
How can i change that?
Im out!
Atm. im building a new website with a adminpanel and of course a login-system. But when i enter the username it's in case-sensivity, which i dont want. Eg. "Lureren" works because that is how its entered in the database, while "lureren" doesnt work?
How can i change that?
Im out!
Re: MySQL-output is case-sensitive?
All the character sets ending with a _ci are case insensitive, so use one of those for the username field.
-
marty pain
- Forum Contributor
- Posts: 105
- Joined: Thu Jun 11, 2009 5:32 am
- Location: Essex
Re: MySQL-output is case-sensitive?
Here you are mate
http://us2.php.net/manual/en/function.strtoupper.php
Convert the user name to upper case before saving it to the database, and again when the user enters their user name to login. Hope that helps!
http://us2.php.net/manual/en/function.strtoupper.php
Convert the user name to upper case before saving it to the database, and again when the user enters their user name to login. Hope that helps!
Re: MySQL-output is case-sensitive?
but then he can't display the username in the original case the user entered it in, which could be confusing / unwanted behavior.
Re: MySQL-output is case-sensitive?
So basicly i just change the characterset in the database?
Re: MySQL-output is case-sensitive?
correct. better backup the table just in case if you have important data in there
Re: MySQL-output is case-sensitive?
Ill give it a try. Thank you 
-
marty pain
- Forum Contributor
- Posts: 105
- Joined: Thu Jun 11, 2009 5:32 am
- Location: Essex
Re: MySQL-output is case-sensitive?
True.pytrin wrote:but then he can't display the username in the original case the user entered it in, which could be confusing / unwanted behavior.
If it's not important, then it's an easy fix, but you're right, sorting out the character set is a better solution.
Re: MySQL-output is case-sensitive?
Ive now tried som different charactersets, but none of them works.
Any suggestions?
Any suggestions?
Re: MySQL-output is case-sensitive?
which ones did you try? you should be using a character set that matches your page encoding, regardless. There shouldn't be that many that match
Also, read the manual - http://dev.mysql.com/doc/refman/5.0/en/ ... ivity.html
Also, read the manual - http://dev.mysql.com/doc/refman/5.0/en/ ... ivity.html
Re: MySQL-output is case-sensitive?
The webpage is using ISO-8859-1 and in the table ive tried latin1_danish_ci, latin1_swedish_ci, latin1_general_ci, utf8_general_ci and utf8_danish_ci.
Re: MySQL-output is case-sensitive?
either of the latin ci's should work. What is the query you are running?
Re: MySQL-output is case-sensitive?
Code: Select all
$postUsername = $_POST["username"];
$sql = mysql_query("SELECT username,password FROM user WHERE username = '$postUsername'");
$sqlArray = mysql_fetch_array($sql);
if($sqlArray["username"] == $_POST["username"] AND $sqlArray["password"] == md5($_POST["password"]))
{
$_SESSION["logon"] = $postUsername;
}
else
{
echo "<p>Wrong login!</p>";
}Re: MySQL-output is case-sensitive?
What you are doing is kind of redundant though I don't think it's related to you error. Since you are retrieving a row by its username, you only have to check that the results are not empty, not compare again the username. You should check that your query produces no errors and that any rows has been retrieved.
Re: MySQL-output is case-sensitive?
I removed the "== $_POST["username"]" and now it works!
Thanks alot!
Thanks alot!