Insert with accent and latin1 characters

I have next table in my database of MySQL:

CREATE TABLE cities ( 
    idcity int(10) unsigned NOT NULL auto_increment, 
    city varchar(50) NOT NULL,
    PRIMARY KEY  (idcity), 
) ENGINE=latin1  DEFAULT CHARSET=latin1; 

I will have around 8000 cities (aprox) and my query is right:

INSERT INTO cities (city) VALUES ('Barcelona'),('Álava'), ('Cáceres'), ... until 8000 cities of Spain.

What I don't want to do it is to use in PHPutf8_decode because I have 8000 registers.

In PHP I have the insert inside a string and after I execute the query. table creates right as latin1

How can MySQL recognize the accents of that cities?


There's absolutely no need to encode data manually (and please don't ever use utf8_decode() without looking up in the PHP manual what it actually does).

Most likely, you're failing to set the connection encoding when you connect to MySQL:

Now, don't type utf8 blindly. You need to find out what encoding your app is using.

Simply use utf8_general_ci collation in SQL table for your city varchar.

Need Your Help

How to track a completed file download in ASP.NET file download google-analytics monitoring

I have this ASP.NET web site that allows users to download program installation packages (just normal files). I want to be able to track when a download is completed (i.e. the file has been fully

Request to Asp page misses if called very fast

javascript performance asp-classic

I have a website with is made in classic asp. On one page there are 5 textboxes and 5 labels. When users type some value in the textbox then using javascript (added on Onchange event) another asp p...