简体   繁体   中英

how to insert upper case in mysql

i would like to know how to insert a upper case in mysql. i have a form that ask the user for their name, when they enter their for example tom brown. I would like to insert this into the db as Tom Brown instead. where would i need to put ucfirst for this to happen. i tried

$info = mysql_query("INSERT INTO workname(email,fname,lname,gender,position) VALUES
                   ('$email',ucfirst'$fname',ucfirst'$lname','$gender','$position' )"); 
      // didn't work

$info = mysql_query("INSERT INTO workname(email,fname,lname,gender,position) VALUES
            ucfirst('$email','$fname','$lname','$gender','$position' )");
  // not what i want, didn't work

$info = mysql_query("INSERT INTO workname(email,fname,lname,gender,position) VALUES
              ('$email',ucfirst('$fname'),ucfirst('$lname'),'$gender','$position' )");
 //  didn't work

Please help where and what am i doing wrong.

is this php? try this.

$info = mysql_query("INSERT INTO workname(email,fname,lname,gender,position) VALUES
     ('$email','".ucfirst($fname)."','".ucfirst($lname)."','$gender','$position' )");

or this much better

$fname = ucfirst($fname);
$lname= ucfirst($lname);

$info = mysql_query("INSERT INTO workname (email,fname,lname,gender,position) VALUES
                          ('$email','$fname','$lname','$gender','$position' )");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM