473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

convert variables to lowercase before comparing

150 100+
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
5 2504
Markus
6,050 Expert 4TB
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
1,168 Expert 1GB
[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
1,654 Expert 1GB
[php]if(strtolower($R['User']) == strtolower($User))[/php]
Mar 2 '08 #4
smartic
150 100+
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
4,258 Expert 4TB
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

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

Similar topics

23
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner,...
30
by: rh0dium | last post by:
Hi All, While I know there is a zillion ways to do this.. What is the most efficient ( in terms of lines of code ) do simply do this. a=1, b=2, c=3 ... z=26 Now if we really want some...
5
by: Son KwonNam | last post by:
I have some very huge(4~600MB) XML file which is in XML Native database - eXcelon. The problem is that I need to convert all the xml elements' names to lowercase. I think I could do this with...
11
by: John | last post by:
Hi, I encountered a strange problem while debugging C code for a Windows-based application in LabWindows CVI V5.5, which led me to write the test code below. I tried this code with a different...
4
by: Mika M | last post by:
I need to compare two DateTime variables named as t1 and t2 using VB.NET 2003. If t1 is any earlier time as t2, only then program should do something like... If (t1 < t2) Then...
2
by: John Salerno | last post by:
After reading the PEP, I'm still not quite sure if there is a recommended (or widely preferred) method of naming variables. Here are the relevant bits: > Global Variable Names > > (Let's...
22
by: federico_bertola | last post by:
Hi everybody, I have an array of chars that I want to make all lower int Scan(char Search) { char *cPtr; cPtr = strtok (Search," -,."); while (cPtr != NULL) {
6
by: BSHELTON | last post by:
How do I convert existing lowercase data to uppercase in Access 2000? I used the following which did not work? UPDATE HousingTowns SET tMunis=UPPER(tMunis); "HousingTowns" is the table name....
5
by: jlbess | last post by:
I'm using the following code in a C++ dll to retrieve the windows username of the current logged in user. I'm passing the username to a case sensitive application so I need to convert it to all lower...
1
by: mk | last post by:
http://www.python.org/dev/peps/pep-0008/ "Function Names Function names should be lowercase, with words separated by underscores as necessary to improve readability." However, this PEP does...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.