Forums / Upgrading from 1.3.x to 1.3.9 / ability to define DB_CHARSET in v1.3.9?

ability to define DB_CHARSET in v1.3.9?

Views: 46,696

Results 1 to 20 of 36
26 Apr 2010, 1:44 PM
#1
davico avatar

davico

New Zenner

Join Date:
Nov 2009
Posts:
12
Plugin Contributions:
0

ability to define DB_CHARSET in v1.3.9?

hello all
i see in the new version that :

Added ability to define DB_CHARSET to automatically trigger a mysql SET NAMES statement if needed for things like UTF8 support, preventing the need to edit the db class

so where should i define this???

26 Apr 2010, 5:26 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: ability to define DB_CHARSET in v1.3.9?

Create a new file for it:

/includes/extra_configures/my_db_charset.php

<?php define('DB_CHARSET', 'your_charset_here');

Do the same with: /**admin/**includes/extra_configures/my_db_charset.php

NOTES:

  • This is** only applicable to v1.3.9x.** It will NOT work in older versions, and is not applicable to the future versions after v1.5.0 since they will be utf8 already.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Apr 2010, 6:58 PM
#3
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

I had to add this line of code when I upgraded to php 5 [ZenCart 138 code doesn't set the encoding of the client connection, so when connecting to a MySQL 5 server, the server will return utf-8 encoded text.]

the code added to includes/classes/db/mysql/query_factory.php line 36:

    mysql_set_charset('latin1');

Should I keep this or go with the new code ```php
/includes/extra_configures/my_db_charset.php <?php define('DB_CHARSET', 'your_charset_here');


I plan to upgrade this week to 1.39a

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

26 Apr 2010, 8:20 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: ability to define DB_CHARSET in v1.3.9?

Using the DB_CHARSET define replaces the need for editing query_factory.php, so you should remove your custom code from that file.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Apr 2010, 8:24 PM
#5
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

thanks dr byte! :bigups:

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

27 Apr 2010, 11:00 AM
#6
davico avatar

davico

New Zenner

Join Date:
Nov 2009
Posts:
12
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

thank you :clap:

11 May 2010, 9:32 PM
#7
nagelkruid avatar

nagelkruid

Zen Follower

Join Date:
Nov 2006
Posts:
284
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

hello, can you please help me out, no matter what i try i keep running into error during install:

 1366 Incorrect string value: '\xA3:&eur...' for column 'configuration_value' at row 1
in:
[INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Convert currencies for Text emails', 'CURRENCIES_TRANSLATIONS', '£,£:€,€', 'What currency conversions do you need for Text emails?
Default = £,£:€,€', 12, 120, NULL, '2003-11-21 00:00:00', NULL, 'zen_cfg_textarea_small(');]

i have created my_db_charset.php in /includes/extra_configures & in /admin/includes/extra_configures with the line:

<?php define('DB_CHARSET', 'utf8');
``` to no avail...
 
The server specs:
<LI id=li_server_version>Server version: 5.1.44-community<LI id=li_mysql_proto>Protocol version: 10
<LI id=li_select_mysql_charset>MySQL charset: UTF-8 Unicode (utf8) 
<LI id=li_web_server_software>Apache/2.2.15 (Win32) PHP/5.3.2<LI id=li_mysql_client_version>MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $<LI id=li_used_php_extension>PHP extension: mysql 
The collation (not sure if it is related) is set to *utf8_general_ci*
 
*This is a clean install on a new server and the default setting seems to be this utf8 setting. I am not the admin of this server and it isn't obvious to me where or how i could chang the character set to latin on the database itself.*
*The database is allready created for me, i can fill it with tables or drop the tables in it, but not alter the database itself.*
 
Any input to resolve would be highly appreciated, thank you
11 May 2010, 11:56 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: ability to define DB_CHARSET in v1.3.9?

Add it to the bottom of /zc_install/includes/installer_params.php ... and keep it in the other locations where you already have it, too.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 May 2010, 9:05 AM
#9
nagelkruid avatar

nagelkruid

Zen Follower

Join Date:
Nov 2006
Posts:
284
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

Thank you for the input.
I added the line like so after the last line in that file:

define('STRICT_ERROR_REPORTING', false);
define('DB_CHARSET', 'utf8');

unfortunately, it results in the exact same error message.

anything else i can try to resolve?

12 May 2010, 3:23 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: ability to define DB_CHARSET in v1.3.9?

You need to say 'latin1' instead of 'utf8'

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 May 2010, 7:05 PM
#11
nagelkruid avatar

nagelkruid

Zen Follower

Join Date:
Nov 2006
Posts:
284
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

DrByte:

You need to say 'latin1' instead of 'utf8'
Ok, i have trouble understanding the logic, but don't have the time to be bothered right now...:P
It is working and extremely happy with that, thank you!

15 Jul 2010, 1:47 PM
#12
sjur_hemma avatar

sjur_hemma

New Zenner

Join Date:
Jul 2010
Posts:
11
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

DrByte, I have the following problem: I have followed the steps to install a new, fresh ZenCart to be utf8 from the start, as described here: srw2d.com/sites/default/files/utf-8-zen-cartV1.3.8.pdf

I also noted the point that for ZC 1.3.9d WHich I am using, you should not modify the query_factory.php but instead create two new files called my_db_charset.php and put them in /yoursite/includes/extra_configures/ and /yoursite/admin/includes/extra_configures/ respectively.

Now: Having done all that and followed through with a new, clean installation without any problems, the result is this: Whether I try to open the front or the administrator back end, I just got the install page all over again, as if nothing had happened. When I remove those two files called my_db_charset.php the front end and back end show up just fine!

What is wrong here?

Now it seems to work fine, but I am afraid that when I next install a spanish language pack and start entering data in both english and spanish that things will get messy....

Thanks very much in advance for an answer.

15 Jul 2010, 9:05 PM
#13
sjur_hemma avatar

sjur_hemma

New Zenner

Join Date:
Jul 2010
Posts:
11
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

Oh, and by the way: Obviously this alternative way of setting the db_charset in a separate file instead of modufying the query_factory.php obviously didn't work at all in my case: After giving the new and fresh database a look I found that all the tables had still been created with latin1 collation!

Now I have manually and painstakingly changed the charset of every field (where specified) in every table, plus the collation of every table to utf8_general_ci. Phuhh.... That's a lot of mouse clicks... I once came across a post that showed a way to do this with SQL scripts, but where was it when I needed it?

Anyways: I would still like to know what to do here, because even though I should be fine now, every time in the future that I add something that creates another database table, obviously I need to manually change this. Please, someone help??

15 Jul 2010, 9:24 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: ability to define DB_CHARSET in v1.3.9?

If the system is completely ignoring the built-in code which properly sets the collation, then it's probably inheriting the collation from the database itself. Thus, changing the database's default collation and character set would be your required next step.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Sep 2010, 1:45 PM
#15
tweedle avatar

tweedle

New Zenner

Join Date:
Jul 2010
Posts:
4
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

DrByte:

Create a new file for it:

/includes/extra_configures/my_db_charset.php

<?php define('DB_CHARSET', 'your_charset_here'); ``` > Do the same with: /**admin/**includes/extra_configures/my_db_charset.php > > > NOTES: > - This is** only applicable to v1.3.9x.** It will NOT work in older versions, and is not applicable to the future version v2.x since it will be utf8 already. Hi all, this worked perfectly for German with utf8 and the '?>' at the end of the php file.

Many thanks to all

Regards,

Jack

1 Sep 2010, 5:14 PM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: ability to define DB_CHARSET in v1.3.9?

tweedle:

and the '?>' at the end of the php file.
Jack, that '?>' is not necessary: https://www.zen-cart.com/tutorials/index.php?article=313

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

8 Nov 2010, 8:06 PM
#17
parkerlewis avatar

parkerlewis

New Zenner

Join Date:
Jun 2009
Posts:
11
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

Hi all. I have been successfully using Zen Cart for 2 years now....Me and my wife work at it full time, doing an online bicycle shop.

Anyway, I am about to build a separate shop and am trying to get the UTF-8 settings sorted.

I have 1.3.9 and so do not need to modify query_factory.php

I just can not understand what I am meant to do instead.... sorry for being so ignorant. I just find the instructions on this thread too brief/vague to get my head around.


Here are my questions regarding DRBYTES post/instructions....


DrByte said//

Create a new file for it: * (((I do this by making a new file in smultron or text editor?)))*

/includes/extra_configures/my_db_charset.php
Code:

<?php define('DB_CHARSET', 'your_charset_here');* (((so I type UTF-8 in this space between the apostrophes?)))* Do the same with: /admin/includes/extra_configures/my_db_charset.php ------ I hope that makes sense.....:blush:
13 Nov 2010, 3:16 PM
#18
christian_f avatar

christian_f

New Zenner

Join Date:
Nov 2010
Posts:
1
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

Thanks DrByte! This was great help to us in fixing the correct display of our German language files.

15 Mar 2011, 4:36 AM
#19
cjcraven avatar

cjcraven

Zen Follower

Join Date:
Aug 2004
Location:
Osaka Japan
Posts:
149
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

DrByte:

Create a new file for it:

/includes/extra_configures/my_db_charset.php

<?php define('DB_CHARSET', 'your_charset_here'); ``` > Do the same with: /**admin/**includes/extra_configures/my_db_charset.php > > > NOTES: > - This is** only applicable to v1.3.9x.** It will NOT work in older versions, and is not applicable to the future version v2.x since it will be utf8 already. Created and uploaded as outlined, the result is a DB collation of latin1_general_ci in the tables, I am now manually changing each field. Adding the 2 files causes the store and admin screen to go blank. I'm not clear why I had this problem.
15 Mar 2011, 12:11 PM
#20
cjcraven avatar

cjcraven

Zen Follower

Join Date:
Aug 2004
Location:
Osaka Japan
Posts:
149
Plugin Contributions:
0

Re: ability to define DB_CHARSET in v1.3.9?

I found the reason for blank store and admin pages in my case was a simple mixup of admin and store english.php files. Putting the correct files in place corrected the problem.