By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

convert variables to lowercase before comparing

100+
P: 150
i need to know how can i compare two strings one from database uppercase ex:'SmaRtic' and the other lower case ex:'smartic'.

that is my code when the user post his data :

[PHP]$QUERY = mysql_query("SELECT User FROM users WHERE User='$User'");
$R = mysql_fetch_assoc($QUERY);
if(strtolower($R['User']) == $User){
$errors['username']='Someone has already chosen that username. Please choose another one!.';
}[/PHP]
Mar 2 '08 #1
Share this Question
Share on Google+
5 Replies


Markus
Expert 5K+
P: 6,050
i need to know how can i compare two strings one from database uppercase ex:'SmaRtic' and the other lower case ex:'smartic'.

that is my code when the user post his data :

[PHP]$QUERY = mysql_query("SELECT User FROM users WHERE User='$User'");
$R = mysql_fetch_assoc($QUERY);
if(strtolower($R['User']) == $User){
$errors['username']='Someone has already chosen that username. Please choose another one!.';
}[/PHP]
Does that not work?
It looks like it should..
Mar 2 '08 #2

TheServant
Expert 100+
P: 1,168
[PHP]$QUERY = mysql_query("SELECT User FROM users WHERE User='$User'");
$R = mysql_fetch_assoc($QUERY);
if(strtolower($R['User']) == $User){
$errors['username']='Someone has already chosen that username. Please choose another one!.';
}[/PHP]
How about instead trying:

[PHP]$QUERY = mysql_query("SELECT User FROM users WHERE User='$User'");
$R = mysql_fetch_assoc($QUERY);
if(strtolower($R['User']) == $User){
echo('Someone has already chosen that username. Please choose another one!');
}[/PHP]
Mar 2 '08 #3

hsriat
Expert 100+
P: 1,654
[php]if(strtolower($R['User']) == strtolower($User))[/php]
Mar 2 '08 #4

100+
P: 150
it work when i use this code why ?
[PHP]
SELECT `user` FROM `users` WHERE `user` = CONVERT( cp1256 'smartic' USING utf8 ) [/PHP]
Mar 3 '08 #5

ronverdonk
Expert 2.5K+
P: 4,258
it work when i use this code why ?
[PHP]
SELECT `user` FROM `users` WHERE `user` = CONVERT( cp1256 'smartic' USING utf8 ) [/PHP]
That is not lowercase conversion or comparison.

Ronald
Mar 3 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.