Insert in mysql with strtoupper is not accepting numbers and letters

2

I'm doing the following insert:

<?php 
include "conexao.php";
  $v_tipo         = $_POST ["tipo"];
  $v_funcao       = $_POST ["funcao"];
  $v_numero       = $_POST ["numero"];
  $v_responsavel  = strtoupper($_POST['responsavel']);
  $v_tag          = strtoupper($_POST['tag']);
  $v_loja         = $_POST ["loja"];
  $v_local        = strtoupper($_POST['local']);
  $v_conteudo     = strtoupper($_POST['conteudo']);


      $insert = "INSERT INTO refrigeracao 
                                (refri_id,
                         refri_tipo,
                         refri_funcao,
                         refri_numero,
                         refri_responsavel,
                         refri_tag,
                         refri_loja,                         
                         refri_local,
                         refri_conteudo) 
                           VALUES (NULL,
                                   '$v_tipo',
                                   '$v_funcao',
                                   '$v_numero',
                                   '$v_responsavel',
                                   '$v_tag',
                                   '$v_loja',
                                   '$v_conteudo',
                                   '$v_local')"; 

            mysql_query($insert);


 echo '<script>alert(\'Dados cadastrados com sucesso!\');parent.location =\'index.php\';</script>';

?>

And I'm using strtoupper when the user type lowercase letters automatically saves them in uppercase, when the field is only text is working, more in the case of $v_tag = strtoupper($_POST['tag']); that is numbers and letters is saving only the numbers, what could be wrong?

    
asked by anonymous 10.05.2016 / 17:02

2 answers

3

Another way to solve this problem is to use the upper() function of MySQL so the string is already converted into the insert.

Example:

select upper('1c2b33cd') #1C2B33CD 
    
10.05.2016 / 17:25
1

Another solution is to use the mb_strtoupper () function of PHP

    
10.05.2016 / 17:52