-1
I work for a reseller of lodgings and I have a strange problem...
I recently acquired a server in ALOG, before I had a server in the hostgator, so I exported it through the Cpanel schema of all accounts.
Every site on this server has a PHP control panel to feed a Mysql database, the data registered in this panel before the migration, even after the migration are perfect, special characters, all clean.
First strange fact.
To) Once on the new server, I decide to register the word "Are", he saves "Are in the bank, da para ver pelo phpMyAdmin.
B) On the old server, when saved the word "are", I see in phpMyAdmin the word are like this : "SANE"
Cool that always worked like this, when in the frontend of the site I search in the bank, it returns me always the correct word.
As I exported the account, all charset settings of the sign-up files/view files are equal, so are the database settings.
Okay, I always wondered why it worked in the B way, but I was happy because it worked.
in my WHM, my php.ini
is configured with charset iso-8859-1
same as my old server.
1st Problem:
But there appears the first problem, the words on the panel appear without the correct accentuation, for example "Description", appears "Description§§§§§§", now how? the charset is the same! the file is the same, the database has been exported and imported..
if I switch to utf-8, ready! works and appears right, but then the server is different the configuration, the new utf-8, the old iso-8859-1, I live with it, alive, but the problem is that there are more problems so I try to leave the 2 equal to go eliminating possibilities.
2nd problem: This is strange... I created a page, this page is with the metatag
<meta charset="utf-8" >
but her encoding is iso-8859-1
.
the bank is like latin1_swedish_ci
that is iso-8859-1
right? the table, everything, exactly like the database configuration of my old server, which works.
But when I register words, if they end with special characters, the problem
for example the phrase "is dull ó data, ã, implicit, meeting" when saved, it saves "is dull ó data, ã, implicit, meeting" in the bank and at the time of showing it shows "is dull ó data, ã, implicit, meeting"
but if I put some special character at the end, like "reuniã" it disappears me with the last character and shows nothing!
But if I put 2 special characters, then he obeys, like "meek," then he shows. Can you understand? if I put the only letter "Is" doesn’t work, if I put "ÉÉ" works!!
if you don’t believe, take a look http://www.heytec.com.br/test/
And that’s as much as I could, because even though I knew this configuration was correct because it works on the other server, I changed it and says all possible combinations.
had time to return me "?" and worse, this was as far as I got!
Can any charitable soul give me a light?? I haven’t slept for 2 days because of it.
DIRECT SEARCH IN PUTTY IN 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 IN DATABASE, OLD SERVER
select * from dados;
+----+-----------+
| id | valor |
+----+-----------+
| 1 | maça |
| 2 | olá |
| 3 | teste |
+----+-----------+
3 rows in set (0.00 sec)
One detail I forgot to mention, is that if I search the variable for POST, it already has the problem, and if I put the special character directly in the query, it works, the problem is in the rescue of it in PHP, now because I do not know, apache? config in the php.ini
?
I just returned the php.ini
as utf8, so I can have the data that has already been registered in order.
so gets my test environment screen
"� ma�aa � dados, �, impl�cito, reuni�o"
---------------------- CONFIG PHP NEW SERVER
www.heytec.com.br / test/ test.php
---------------------- CONFIG PHP OLD SERVER
162.144.115.36 / ~heytecco / test/
Description§means that the data is recorded in the BD as utf-8 but being shown in iso-8859-1, OU is going through 2 UTF-8 encodings by mistake. View the binary data in the database, and add the question to be sure (can be converted to hexadecimal).
– Bacco
I took your test and it’s all right here with the accent. http://i.stack.Imgur.com/z5bIx.png - High chance of BD being in UTF-8 even, and by displaying in iso, does not come out right.
– Bacco
test putting only a special character, type IS, or putting only one in the whole sentence and it at the end!
– Danilo Ribeiro
For starters, you are mixing a UTF-8 page with an iso form, what’s the idea? It seems to me that you are trying to solve by trial and error. If it’s for testing, you can try for UTF-8 at all and display the old database data to see if it works. In addition, you need to test everything without utf8 Access/Code in PHP, otherwise it becomes crazy. Charset is a very simple thing, the problem is that few people spend time to understand, and so we see problems with it all the time.
– Bacco
Precisely, I am in trial and error, I have left everything in UTF-8, I have left everything in ISO, I have already mixed the 2, that there was the config that I got closer to the solution, if I leave php.ini in utf8 it does not give me problem in display of the old data, but the default config is iso on the old server, I’m not getting anything.!
– Danilo Ribeiro
Mixed will always give problem. The important thing is you detect how the data is. The best would be to see the bytes, then you would be absolutely sure. All indicates that it is UTF-8, but only analyzing the bytes numerically instead of playing on the screen.
– Bacco
Friend Danilo I advise you to install an automatic corrector, to correct errors in your text.
– Jorge B.
@Danilo, take your urgent form off the air, It is completely open to do SQL Injection. Jajá some joker erases your entire BD.
– Bacco
is a test comic, on a test account, has nothing in it, is soh to try to solve the problem, thanks for the concern!
– Danilo Ribeiro
For the test page set the communication with the database to utf-8, I’m not sure what extension of PHP you’re using, but here’s a way to do this: http://php.net/manual/en/function.mysql-set-charset.php and please save the document as utf-8 as well, or I’ll create a new one.
– Édipo Costa Rebouças
http://php.net/manual/en/mysqlinfo.concepts.charset.php. on this page you will find information on how to configure the charset for other pages. but still, making it work on the test page is different from making it work on the system.
– Édipo Costa Rebouças
When I do this, if these charset configs, the error passes to ??? ma??? aa ???? data, ??? impl???? quote, reuni???? o, I had already done these tests, I remade them now by way of doubt, tb created a new utf8 file for testing, nothing... Have a thing, when sending from and a form, a word like "apple" per post, and give an echo $_POST[field] it already returns me with problem, without even inserting in the comic
– Danilo Ribeiro
maybe it’s something with the same server. if you give the post and the character already comes indecipherable hehe. see if the solution to this link resolves http://www.howtoforge.com/forums/showthread.php?t=27230
– Édipo Costa Rebouças
I’ll test it, buddy, I’ll answer you, thanks!
– Danilo Ribeiro
Buddy, you know how I can do that at the WHM??
– Danilo Ribeiro
I managed to make the change directly by SSH, but I was not successful, I tested all the options cited in the presented forum. = [ I think I’ll go back to the old server.. q Zica..
– Danilo Ribeiro
you restarted the apache?
– Édipo Costa Rebouças