Insert in mysql with strtoupper not accepting numbers and letters

Asked

Viewed 293 times

3

I am 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 the strtoupper for when the user type minute letters automatically save them in uppercase, when the field is only text this working,more in the case of $v_tag = strtoupper($_POST['tag']); which is numbers and letters this saving only the numbers, ?

  • Give an example of this tag is to work, other options are mb_convert_case or do this in the database.

  • 1

    refri_tag is sweep?

  • yes it is varchar yes

  • example how to save: 1C2B33CD even if the user typed 1c2b33cd

  • 1

    The problem does not seem to be this code, it goes straight to the bank, there in the Insert change to: upper('$v_tag'),

  • perfect. Thanks. More then I will see the PHP documentation and see why otherwise did not work out, more straight in the bank was. Thanks again.

  • So the description of the problem does not match the code, it seems to have something external causing this situation.

  • As well,I did not understand it well, ?

  • 2
  • 1

    For example run, echo strtoupper('ação 2015');, do not check the accented characters is expected, but 'cut' the letters does not, so said, seem to have something external interfering.

  • I get it,.

  • @Guilherme Lautert Great article, I’m already studying the PDO for migration. Thank you

  • Possible duplicate of php strtoupper() with accents

Show 8 more comments

2 answers

4


Another way to solve this problem is to use the function upper() Mysql so the string is already converted to Insert.

Example:

select upper('1c2b33cd') #1C2B33CD 

1

  • I will also test is return.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.