Accented words are not sent to the database - PHP

0

I made a form that sends data from a php page to a database, and only the unencrypted data is being sent; if I put an accent, nothing in that field arrives in the database, not even something blank.

Thanks in advance for any help

Code snippet:

<textarea cols=\'20\' rows=\'10\' name=\'text\'></textarea>
<input type="submit" value="Enviar" name="enviar"> 

if(isset($_POST['enviar'])){

$teste2 = $_POST['text'];

mysql_query("INSERT INTO 'testes'('texto') VALUES ('".$teste2."');
    
asked by anonymous 07.11.2017 / 19:38

2 answers

1

Some symbols are not accepted because they can be used to enter the database through MYSQL Injection .

One way to do this is to use htmlentities and htmlspecialchars which will replace these symbols with the equivalent of html, that is:

$texto = htmlspecialchars(htmlentities($_POST['text']));
    
07.11.2017 / 19:59
0

There are many situations that can cause this to happen

  
  • The way you generated your table "unicode_utf8" ??
  •   
  • How are you handling your strings?
  •   
  • Verify that you are using utf8_encode and utf8_decode correctly.
  •   
  • See if you are using filter_var () correctly.
  •   
  • I recommend you also use PDO to manipulate data is more secure.
  •   

I do not know if the bars were needed more you can do this way without '\'

<textarea cols='20' rows='10' name='text'></textarea> <input type="submit" value="Enviar" name="enviar">

    
07.11.2017 / 20:38