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. Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted February 5, 2008 Author Share Posted February 5, 2008 i also tried ucwords(strtolower($string)); Quote Link to comment 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. Quote Link to comment 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); Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted February 5, 2008 Author Share Posted February 5, 2008 im stupid, nevermind Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.