Page 1 of 1
MySQL... uhm. Naming
Posted: Fri Feb 16, 2007 9:31 pm
by Mightywayne
I was wondering how to make my MySQL entries auto-cap. :X) I'm pretty sure it's super-simple but I don't even know what to search for in Google.
I basically want it to be able to cap everyone's name instantly. It's also be nice if I could stop users from having ANNOYING NAMES IN CAPS too but that's a minor issue.
Posted: Fri Feb 16, 2007 9:44 pm
by Luke
I'm not sure I know what you're asking. Are you trying to have the username field appear in all caps? if that is the case, just capitalize it right before outputting it...
Code: Select all
<?php
// ... get mysql row ...
$name = $mysql_row['username'];
echo strtoupper($name);
// ... do some other stuff ...
?>
Posted: Fri Feb 16, 2007 9:57 pm
by Mightywayne
Err, no, it's more of a server-side thing. Like, no matter what the user enters in the field,
bObErInO = Boberino
Regardless of capitalization.
I guess I could do it with PHP, but I was looking for more of a mysql-table sorta thing. Like how you could technically not have to use auto_increment, but you can also just use it.

Posted: Fri Feb 16, 2007 10:22 pm
by DrTom
You could always use MySQL's UPPER/UCASE built in function so like uhmm
Code: Select all
SELECT * from my_table_of_awesome_random_cased_words WHERE UCASE(word)=UCASE('myWordIwAnTToSearChTheETabLeFor')
Posted: Sat Feb 17, 2007 3:41 am
by Mordred
If it's about the latin charset, easy:
Code: Select all
$name = ucfirst(strtolower($name));
Posted: Sat Feb 17, 2007 6:37 am
by Mightywayne
Alright, thanks guys, I guess I'll just do it with PHP at first, then. <3
Posted: Sat Feb 17, 2007 8:44 am
by feyd
MySQL, along with many other databases will match any case variant by default unless the field is considered to have the BINARY attribute.