Script does not save full word if it has accent

Asked

Viewed 21 times

0

I have a script that works very well on my Dashboard, but I put it on another page and is not working.

When a word has accent, eg: "Natalia" the system is saving in bd only "Nat" excluding the rest that is part of the word.

include "painel_dados/bd.php";

// recebendo os dados do formulario
$nome   = $_POST['nome'];
$cpf    = $_POST['cpf'];

$query = $mysqli->prepare('INSERT INTO `associados` (`nome`, `cpf`) values (?,?)')or die($mysqli->error);
$query->bind_param('ss', $nome, $cpf);
$query->execute();

Where am I wrong? If I give a

echo $name;

the word appears right. Only when saving in the comic it will incomplete.

  • Make sure your bank is in utf-8 format.

  • It is. I discovered the problem. The error was on the page where the form was, it was in iso

  • 1

    Good thing you figured out why with the code posted we would never find out.

1 answer

2

I found the mistake. The page where the form was with

charset=iso-8859-1

I switched to

UTF-8

And it worked

Browser other questions tagged

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