Problems with accentuation in Postgresql and PHP characters

Asked

Viewed 207 times

0

Hello! I’m having trouble saving data from a PHP form in Postgresql.

Currently the database is LATIN1 and the pages are with Charset in UTF8. However I have tested with Postgresql in UTF8 and the same situation occurs.

After submitting the form and printing the SQL script the data to be saved is as expected, but in the database the data is saved as the example below.

Value to be saved: Accentuation.

Value saved in database: Accent§.

I appreciate the help :D

  • Have you tried using in Postgresql: SET CLIENT_ENCODING TO 'LATIN1';? Postgresql is probably considering that the client encoding is not LATIN1 (check using SHOW CLIENT_ENCODING;).

1 answer

0


Before saving form information, use UTF8_DECODE. Here’s an example:

<?php
$nome = $_POST["nome"];
$StrSQL = "INSERT INTO minha_tabela (nome) VALUES ('" . utf8_decode($nome) . "')";
//Programação para gravar no banco de dados....
?>

To view information recorded in the database, use utf8_encode()

Browser other questions tagged

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