0

I want do such as this:

$username0 = $_POST["nkn"];
$username1 = strtoupper($username0);
$query = "SELECT username FROM users WHERE strtoupper(username) = '".$username1."'";

What's the right way to do this? Thanks.

5
  • What do you want to achieve? Commented Jun 21, 2013 at 13:12
  • You mean to modify and update the values ? Commented Jun 21, 2013 at 13:13
  • See stackoverflow.com/questions/60174/… Commented Jun 21, 2013 at 13:13
  • use a case insensitive collation where you don't need any index killing functions. Commented Jun 21, 2013 at 13:13
  • 1
    and beware sql injections. Commented Jun 21, 2013 at 13:14

1 Answer 1

2

Use the below code:

$query = "SELECT username FROM users WHERE UPPER(username) = '".$username1."'";

In mysql the is the function UPPER() to convert the string in upper case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.