mikefrederick Posted February 5, 2008 Share Posted February 5, 2008 need help capitalizing words from a form. i am submitting the values of the form into a database and have tried ucwords() and mb_convert_case(), both times only lowercase letters were entered into the database. Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/ Share on other sites More sharing options...
mikefrederick Posted February 5, 2008 Author Share Posted February 5, 2008 i also tried ucwords(strtolower($string)); Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459208 Share on other sites More sharing options...
PHP Monkeh Posted February 5, 2008 Share Posted February 5, 2008 Can we see the code where you take your post variables, try converting them using ucwords() and then your query please It might be an issue with something other than the function. Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459209 Share on other sites More sharing options...
mikefrederick Posted February 5, 2008 Author Share Posted February 5, 2008 $x is the posted variable, always enters lowercase. $ee=strtolower($x); $dd= ucwords($ee); $qr="insert into citiez (cname,sid) values ('$cname','$dd')"; mysql_query($qr); Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459211 Share on other sites More sharing options...
Dorac Posted February 5, 2008 Share Posted February 5, 2008 strtoupper($value) always worked for me hey. get the entered data from the form, upcase it, stick it in the database. simple also... make sure your variables are named the same and you not upcaseing a non-existent variable Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459216 Share on other sites More sharing options...
mikefrederick Posted February 5, 2008 Author Share Posted February 5, 2008 if it was non-existent then it wouldn't enter in the first place, and thanks but I want to capitalize the first letter of every word. Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459220 Share on other sites More sharing options...
PHP Monkeh Posted February 5, 2008 Share Posted February 5, 2008 Try echo-ing out the variables before insert them in to the database, or echo your query just to see exactly what you're trying to insert. Also please add or die(mysql_error()) on to the end of your query, it's just good practice! Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459223 Share on other sites More sharing options...
mikefrederick Posted February 5, 2008 Author Share Posted February 5, 2008 im stupid, nevermind Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459228 Share on other sites More sharing options...
Dorac Posted February 5, 2008 Share Posted February 5, 2008 i agree with PHP Monkeh, change your code to... $ee=strtolower($x); $dd= ucwords($ee); echo "$ee is ".$ee."<b r>"; echo "$dd is ".$dd."<b r>"; //(those are breaks btw) // $qr="insert into citiez (cname,sid) values ('$cname','$dd')"; // mysql_query($qr) // or die("Query failed: <br>".mysql_error(); That should work for you to debug it Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459231 Share on other sites More sharing options...
marcus Posted February 5, 2008 Share Posted February 5, 2008 <?php $x = "potAtoEs"; $ee = strtolower($x); $dd = ucwords($ee); echo '$x is defined to ' . $x . '<br>'; echo '$ee is defined to ' . $ee . '<br>'; echo '$dd is defined to ' . $dd; ?> $x is defined to potAtoEs $ee is defined to potatoes $dd is defined to Potatoes Dorac your's will not work. Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459242 Share on other sites More sharing options...
Dorac Posted February 5, 2008 Share Posted February 5, 2008 besides the '<br>' s needing to look like that and a ")" at the end of my code after mysql_error(). Why wouldn't it work? dont get me wrong, im not being moody... i just want to learn from my mistake Link to comment https://forums.phpfreaks.com/topic/89622-capitalizing-words-w-php-help/#findComment-459253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.