Accents with mysql and php

0

I am making an application and my goal is that from the form you enter the data with accents and ñ, and that in the BD are stored the same.

It turns out that when executing the following query through PHP with PDO (from the backend of the application):

INSERT INTO familia VALUES(0,'áááéééíííóóóúúúñññ','A','','','');

In the DB it is stored as:

áááéééíííóóóúúúñññ

What should I do to have the chain saved correctly in the database? The script of the table is as follows:

CREATE TABLE 'familia' (
'fam_codigo' bigint(20) unsigned NOT NULL AUTO_INCREMENT,
'fam_descripcion' varchar(100) NOT NULL,
'fam_estado' varchar(1) NOT NULL,
'fam_usureg' varchar(20) NOT NULL,
'fam_fecreg' date NOT NULL,
'fam_horreg' varchar(8) NOT NULL,
UNIQUE KEY 'fam_codigo' ('fam_codigo'),
KEY 'fam_codigo_2' ('fam_codigo'),
KEY 'fam_codigo_3' ('fam_codigo')
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb4;
    
asked by Mario Ramos 24.03.2018 в 23:09
source

1 answer

3

You need to change your charset to one that accepts centers and ñ

ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;


ALTER TABLE familia CONVERT TO CHARACTER SET utf8_general_ci;
    
answered by 24.03.2018 в 23:19