Zen Cart Logo
Forums / General Questions / Yesterday everything was all right. Today I have Encoding problem

Yesterday everything was all right. Today I have Encoding problem

Views: 1,255

Results 1 to 11 of 11
7 Apr 2012, 3:39 AM
#1
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Yesterday everything was all right. Today I have Encoding problem

I guess i am the first one getting this thorny problem.
My website went very well until today. All the non-English language becomes wired code, unreadable (like: ?ubo� Kov�?).
Yesterday everything was all right. Today I checked all the encoding setting including in the code and DB. They are still the same, utf8.
Yesterday i did nothing but Empty the activity log file. Every 2 months zen cart automatically advise me to empty it. I don't think this will cause any problem because i did so many times.
What is the possible reason?
I will be greatly grateful if anyone could offer some help.
Thanks

7 Apr 2012, 3:44 AM
#2
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Yesterday everything was all right. Today I have Encoding problem

If you have made no changes Talk to your Host and ask what updates they may have carried out on the server.

also what version of zncart are you using, have you checked the error log on your site especially zencarts /cache folder

7 Apr 2012, 6:45 AM
#3
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Re: Yesterday everything was all right. Today I have Encoding problem

I checked the /cache/ folder. But there is only records of last year. It seems the function doesn't work on my website now.

7 Apr 2012, 6:50 AM
#4
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Re: Yesterday everything was all right. Today I have Encoding problem

I use ZC1.39h

8 Apr 2012, 2:24 AM
#5
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Re: Yesterday everything was all right. Today I have Encoding problem

Yesterday I posted my problem here but got no solution.
I spent all day to study this problem.
My ZC1.39h store suffered encoding problem 2 days before. Non-English language can not be displayed correctly. That morning l logged in to my admin and got an error of DB connection (I didn't save the error information, which i regret so much now). Then i refreshed the page. The error is gone and the log in page display. Then i logged in and found this problem.
My ZC store' charset is utf8. I changed following this page: https://www.numinix.com/blog/2011/08/01/changing-the-charset-in-zen-cart-1-3-9-to-utf-8/ It had been working very well for a long time until this problem occur. I checked all the setting following the article above, and everything is the same.
I contacted my server support and checked if the did any updating. They replied that they did nothing on updating but just some unscheduled maintenance work. They confirmed that the php and DB charset is all utf8 by default. I guess i can not get more information from them.
To make sure if the problem is caused by the server problem, i installed now ZC1.50 in my server space and found everything is all right. Now i think it was my store problem.
Last night i found that the encoding problem only exists in ADMIN area. To make further research, i wrote a php file with the following code:

require('includes/application_top.php');
header('Content-Type:text/html;charset=utf-8');
function query($orderID) {
global $db;
$orders_processing = $db->Execute("select delivery_name from ".TABLE_ORDERS. " where ( orders_id =".(int)$orderID.")");
print_r($orders_processing->fields);
}
query(10464501);

I put this file under /MY_STORE/ and run it. Result:
Array ( [delivery_name] => KOGUT Stéphane )
I put this file under /MY_STORE/ADMIN/ and run it (after log in). Result:
Array ( [delivery_name] =>KOGUT St�phane )

I searched 'charset' at my admin and got (i list part of it which i think might be helpful):

/includes/classes/class.phpmailer.php
Line #40 : * Sets the CharSet of the message. 
Line #43 : var $CharSet = "utf8"; 

/includes/extra_configures/my_db_charset.php
Line #0 : <?php define('DB_CHARSET', 'utf8');

/includes/functions/functions_general.php
Line #1518 : function charsetConvertWinToUtf8($string) { 
Line #1525 : * Convert supplied string to/from entities between charsets, to sanitize data from payment gateway 
Line #1529 : function charsetClean($string) { 
Line #1530 : if (CHARSET == 'UTF-8') return $string; 
Line #1531 : if (function_exists('iconv')) $string = iconv("Windows-1252", CHARSET . "//IGNORE", $string); 
Line #1533 : $string = html_entity_decode($string, ENT_QUOTES, CHARSET); 

/elechouse/includes/languages/english.php
Line #47 : // charset for web pages and emails 
Line #48 : define('CHARSET', 'utf8'); 

/includes/languages/MY_TEMPLATE/english.php
Line #41 : // charset for web pages and emails 
Line #42 : define('CHARSET', 'utf8'); 

/ADMIN/includes/extra_configures/my_db_charset.php
Line #0 : <?php define('DB_CHARSET', 'utf-8');

/ADMIN/includes/languages/english.php
Line #64 : // charset for web pages and emails 
Line #65 : define('CHARSET', 'utf8'); 

I really don't know what to do next to find out solution of this problem.:cry:
I will really appreciate if anyone could help me.
Thanks

8 Apr 2012, 2:30 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Yesterday everything was all right. Today I have Encoding problem

The last thing I would do is change ANYTHING related to character sets ON A LIVE SITE.
Once the site is running live, making any changes runs the risk of damaging or losing data in extended characters, similar to what you initially described. Sounds like you've been changing things.

https://www.zen-cart.com/tutorials/index.php?article=414

8 Apr 2012, 2:52 AM
#7
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Re: Yesterday everything was all right. Today I have Encoding problem

Thanks for your fast reply.
But that page doesn't offer helpful information.
Do you mean i should change back to "latin" charset?

8 Apr 2012, 2:55 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Yesterday everything was all right. Today I have Encoding problem

It's not my strongest area of expertise, but the key thing that I do know for certain is that your database content and your database collation and your php file encoding and your html output need to all use the same encoding. If you start changing them in one place, you need to change them in all places.

THE MOST IMPORTANT thing you've said thus far is that "YESTERDAY IT WAS ALRIGHT and suddenly it changed". So, the IMPORTANT thing you need to do NOW is fix whatever you changed yesterday.

8 Apr 2012, 3:51 AM
#9
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Re: Yesterday everything was all right. Today I have Encoding problem

Thanks man
"Yesterday" i didn't change anything about the code. That's why this problem is so strange.

8 Apr 2012, 3:58 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Yesterday everything was all right. Today I have Encoding problem

Perhaps it wasn't you specifically, but it's clearly something that's changed on your website ... so, that could be your files, your database, your server's PHP configuration, your server's Apache configuration, your server's database MySQL configuration, etc etc etc.
So, if it wasn't you personally, you still need to find out who did, and what did they do. Maybe that was your hosting company? Maybe that was someone else who has access to your hosting account? Maybe even a malicious visitor who has hacked into your hosting account in some way.

Your hosting company should be prepared to give detailed answers about your questions related to what they changed on the server, and why.

12 Apr 2012, 1:16 AM
#11
wilsonshen avatar

wilsonshen

New Zenner

Join Date:
Apr 2010
Posts:
53
Plugin Contributions:
0

Re: Yesterday everything was all right. Today I have Encoding problem

Thanks, man
Finally I found it was my database problem. I don't know what exactly the problem is. I just restored my backup database, and then it works well now.