Charset problem PHP + MYSQL + new server [duplicate]

-1

I work with reseller hosting and I'm having a strange problem ...

Recently I acquired a server in ALOG, before I had a server in the hostgator, hence I did the export by the cpanel schema of all the accounts.

Every site on this server has control panel in PHP to feed a MySQL database, the data registered in this panel before the migration, even after the migration they are perfect, special characters, everything clean.

1st Strange Fact.

A) Once on the new server, I resolve to register the word "Are", it saves "They are on the bank, to see through phpMyAdmin.

B) On the old server, when I save the word "Are", I see in phpMyAdmin the word is this way: "Yes"

As I export the account, all the charset settings of the registration files / view files are the same, the same as the bank settings.

Okay, I always wondered why it worked in way B, but I was happy because it worked.

In my WHM, my php.ini is set with charset iso-8859-1 equal to my old server.

1st Problem:

But here the first problem appears, the words in the panel appear without the correct accent, for example "Description", "Description" appears, now how? the charset is the same! the file is the same, the database was exported and imported.

If I move to utf-8, that's it! it works and appears right, but the server is different configuration, the new utf-8, the old iso-8859-1, I live with it, live, but the problem is that there are more problems so I try to leave the 2 equal to go eliminating possibilities.

Second problem: This is strange ... I created a page, this page is with the meta tag

<meta charset="utf-8" > 

but its encoding is iso-8859-1 . the bank is latin1_swedish_ci which is iso-8859-1 right? the table, everything, exactly like the configuration of the bank of my old server, what works.

But when registering words, if they end with special characters, of the problem

For example, the phrase "is maçaa ó data, ã, implicit, meeting" when saved, it saves "is maçaa ó data, ã, implicit, meeting" in the bank and at the time of showing it shows "is maçaa ó data , ã, implicit, meeting "

But if I put some special character at the end, type "reunion" it adds me with the last character and does not show anything!

But if I put 2 special characters, then it obeys, like "reuíã" there it shows. Do you understand? if I post only the letter "IS" does not work, if I post "IS" it works !!

If you do not believe it, take a look at link

And that was the most I could do, because even though I knew that this setting was correct because it works on the other server, I've changed it and it says all possible combinations.

I had the time to return "??" and worse things, that was as far as I got!

Can some charitable soul give me a light ?? to sleep for 2 days because of it.

DIRECT SEARCH ON THE PUTTY IN THE DATABASE - NEW SERVER

                             |
-> +----+----------------------------------------------+
-> |  1 |                                              |
-> |  2 | 1                                            |
-> |  3 | é maçaa ó dados, ã, implícito, reunião       |
-> |  4 | é maçaa ó dados, ã, implícito, reunião       |
-> |  5 | é maçaa ó dados, ã, implícito, reunião       |
-> |  6 | é maçaa ó dados, ã, implícito, reunião       |
-> |  7 | é maçaa ó dados, ã, implícito, reunião       |
-> |  8 | Acentuação 123                               |
-> |  9 | Acentuação 456                               |
-> +----+----------------------------------------------+
-> 9 rows in set (0.00 sec)

DIRECT SEARCH ON THE DATABASE, ANTIQUE SERVER

 select * from dados;
+----+-----------+
| id | valor     |
+----+-----------+
|  1 | ma&#231;a |
|  2 | ol&#225;  |
|  3 | teste     |
+----+-----------+
3 rows in set (0.00 sec)

A detail that I forgot to mention, is that if I retrieve the variable by POST, it's already the problem, and if I put the special special character in the query, it works, the problem is in its rescue in PHP, now because I do not I know, Apache? config no php.ini ?

I have now returned the php.ini as utf8, so that I can have the data that has already been registered in order.

So is my test environment screen

"� ma�aa � dados, �, impl�cito, reuni�o"

---------------------- CONFIGURE PHP SERVER NEW

www.heytec.com/test/test.php

---------------------- PHP CONFIGURE ANCIENT SERVER

162.144.115.36 / ~ heytecco / test /

    
asked by anonymous 03.12.2014 / 17:57

2 answers

1

I believe you created the new database with the wrong charset, and the tables in that database are inheriting this new charset.

See what is the charset of your old database and configure the new one with it.

This does not explain why bank values are being written as html entities, but it does not hurt to try.

    
03.12.2014 / 18:48
0

I've been through the same problem.

Keep this tag in your html:

<meta charset="utf-8" >

And in PHP, use the utf8_encode () function.

Example, considering that the $ variable came from a SELECT:

utf8_encode($variavel);

This normalizes the accents and strips the html.

    
16.06.2016 / 04:37