hosting and accents [duplicated]

0

Good morning everyone! I'm using Hostinger as host, and I do not put it to publicize it, but because the technical service is not able to tell me why despite having the code that I will put below the accents and special characters if they are saved in the database BUT THEY DO NOT RECOVER AS SUCH AS Rare symbols

The first thing in phpmyadmin I select the database and in operations I put a collation utf8_general_ci. Same in each of the tables and fields of type char.

Then already on the php webService:

header('Content-Type: text/html; charset=UTF-8'); 

$link = new mysqli("mysql.hostinger.es","xxxxxxxx","xxxxx","xxxxxx");
if ($link->connect_errno) {
             echo "Fallo al conectar a MySQL: (" . $link->connect_errno . ") " . $link->connect_error;
        }

mysqli_set_charset($link,"utf8");

mysqli_select_db($link,$u356604334_swa);
$link->query("SET NAMES utf8");

That at the time of connecting. Then in each query I use utf8_decode with the string I pull out.

echo utf8_decode( implode(":",$arraySalida)); 

The fact is that at the beginning when entering data in the database, I cut the chain to get an accent, a ñ, ... when I did everything that I have described previously passed from that to put the characters in the database, I from phpmyadmin can see in fields like last name chains Muñoz, Hernández, ... But when I make a select to get those fields, it returns rare symbols ...

Any ideas? Do you recommend any other hosting?

Thank you very much

    
asked by midlab 20.04.2017 в 23:53
source

2 answers

2

Good again, I have found a solution tampered with code, I leave it to you in case you have any problem of the style to serve you:

The first part of the exact same configuration:

The first thing in phpmyadmin I select the database and in operations I put a collation utf8_general_ci. Same in each of the tables and fields of type char.

Then already on the php webService:

header('Content-Type: text/html; charset=UTF-8'); 

$link = new mysqli("mysql.hostinger.es","xxxxxxxx","xxxxx","xxxxxx");
if ($link->connect_errno) {
             echo "Fallo al conectar a MySQL: (" . $link->connect_errno . ") " . $link->connect_error;
        }

mysqli_set_charset($link,"utf8");

mysqli_select_db($link,$u356604334_swa);
$link->query("SET NAMES utf8");

Then at the time of doing the selection I removed the:

  

decode_utf8

echo implode (":", $ arrayExit);

I do not know why it works but it works and it's better not to touch it or think about it ... My reasoning is that it is already in utf8 in the database (you can see the accents and so on) so I just take it out without touching anything else)

Sorry so much, I did not know whether to delete the post or answer it, if the administrators consider it inconvenient no problem in deleting it.

    
answered by 21.04.2017 в 00:02
0

Good, I use www.000webhost.com that they recommended it to me just in stackoverflow. On the web they say they work with Hostinger so I guess there would be no problem if you have to migrate your entire project there. It is very easy to use and they leave things pretty clear. Personally, and it is not for advertising, to do my small projects I'm doing great and they already tell you the prices if you want something more professional.

With the subject of the database and the test tabs try to take a look at the collation of the connection to the server, in my case I have it as I came. On the main page just open phpMyAdmin in general settings I have utf8mb4_unicode_ci and what is the database itself latin1_swedish_ci

    
answered by 21.04.2017 в 00:11