MySQL... uhm. Naming

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

MySQL... uhm. Naming

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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 ...

?>
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post 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. ;)
DrTom
Forum Commoner
Posts: 60
Joined: Wed Aug 02, 2006 8:40 am
Location: Las Vegas

Post 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')
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

If it's about the latin charset, easy:

Code: Select all

$name = ucfirst(strtolower($name));
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Alright, thanks guys, I guess I'll just do it with PHP at first, then. <3
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply