-
ability to define DB_CHARSET in v1.3.9?
hello all
i see in the new version that :
Code:
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???
-
Re: ability to define DB_CHARSET ?
Create a new file for it:
/includes/extra_configures/my_db_charset.php
Code:
<?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.
-
Re: ability to define DB_CHARSET ?
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.]
PHP Code:
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 Code:
/includes/extra_configures/my_db_charset.php <?php define('DB_CHARSET', 'your_charset_here');
I plan to upgrade this week to 1.39a
-
Re: ability to define DB_CHARSET ?
Using the DB_CHARSET define replaces the need for editing query_factory.php, so you should remove your custom code from that file.
-
Re: ability to define DB_CHARSET ?
-
Re: ability to define DB_CHARSET ?
-
Re: ability to define DB_CHARSET ?
hello, can you please help me out, no matter what i try i keep running into error during install:
Code:
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:
Code:
<?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
-
Re: ability to define DB_CHARSET ?
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.
-
Re: ability to define DB_CHARSET ?
Thank you for the input.
I added the line like so after the last line in that file:
Code:
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?
-
Re: ability to define DB_CHARSET ?
You need to say 'latin1' instead of 'utf8'
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
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!
-
Re: ability to define DB_CHARSET ?
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.
-
Re: ability to define DB_CHARSET ?
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??
-
Re: ability to define DB_CHARSET ?
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.
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
Create a new file for it:
/includes/extra_configures/my_db_charset.php
Code:
<?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
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
tweedle
and the '?>' at the end of the php file.
Jack, that '?>' is not necessary: https://www.zen-cart.com/tutorials/i...hp?article=313
-
Re: ability to define DB_CHARSET ?
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:
-
Re: ability to define DB_CHARSET ?
Thanks DrByte! This was great help to us in fixing the correct display of our German language files.
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
Create a new file for it:
/includes/extra_configures/my_db_charset.php
Code:
<?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.
-
Re: ability to define DB_CHARSET ?
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.
-
Re: ability to define DB_CHARSET ?
i use version 1.3.9.. i added my_db_charset.php in admin/includes/extra configures/ and another location
after , in admin panel i used save or update button opening blank page..
please help me!
thanks..
-
Re: ability to define DB_CHARSET ?
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
power35
i use version 1.3.9.. i added my_db_charset.php in admin/includes/extra configures/ and another location
after , in admin panel i used save or update button opening blank page..
please help me!
thanks..
I had simular problem where adding my_db_charset.php to both admin and store /includes/extra_configures/ folders resulted in blank pages. The error was making the statement <?php two times in the file (listed below) a simple editing error.
<?php
/**
* File defines the charcter set of the database
* Put in store/includes/extra-configures/my_db_charset.php and
* admin/indludes/extra-configures/my_db_charset.php
*
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*/
/**
*/
<?php define('DB_CHARSET', 'utf8');
?>
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
Create a new file for it:
/includes/extra_configures/my_db_charset.php
Code:
<?php define('DB_CHARSET', 'your_charset_here');
Do the same with: /
admin/includes/extra_configures/my_db_charset.php
when should i add this file to extra_configures folder?
all tables have been installed in database, the collation is latin1_general_ci, is it too late to add this file? cause the database tables remain latin1_general_ci
perhaps i should change all ENGINE=MyISAM to ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci before i install the cart ?
what do i change all latin1_general_ci to utf8_general_ci now ?
-
Re: ability to define DB_CHARSET ?
Don't go mucking with existing database content. You can't just randomly change charsets on a whim. To do that requires careful alteration of all your existing data, and is an advanced operation you shouldn't be attempting without advanced knowledge of the topic.
-
Re: ability to define DB_CHARSET ?
Wanna thank everyone for this very helpful post. Between this post, the Numinix instructions (which appears to be a basic summary of the information in this thread), and and Dr Byte's cool tool, I got this done in fairly short order.. Of course the store I converted is a dev store with minimal data in it..:smile:
Anyway.. it went smooth as a baby's bottom.. Thanks to all for the information..
-
Re: ability to define DB_CHARSET ?
The numinix instructions are not fully accurate. And they have you touching files that don't need touching (such as the phpmailer file, etc). Use with caution.
AND in v1.5.0+ the change is simplified: just update configure.php
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
The numinix instructions are not fully accurate. And they have you touching files that don't need touching (such as the phpmailer file, etc). Use with caution.
Understood sir.. I used what was useful from all sources taking heed to your other warnings about the Numinix article..:smile:
-
Re: ability to define DB_CHARSET ?
After update to "utf8"
and upload the 2 files
/admin/includes/extra_configures/my_db_charset.php
includes/extra_configures/my_db_charset.php
my home page text big font size - 3
All ez pages also 3 size text .
How can fixed all is 2 size ?
Thanks
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
AND in v1.5.0+ the change is simplified: just update configure.php
Just caught this.. are my eyes deceiving me?? In v1.5 I ONLY need to update the configure.php file??? What if I am upgrading?? do I make this change in the configure before doing the upgrade via the install script??
-
Re: ability to define DB_CHARSET ?
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
Okay based on this part:
Quote:
edit your upgraded english.php file to use the old CHARSET and setlocale settings, as well as edit your configure.php file to set DB_CHARSET to 'latin1'
if I DON'T need to convert, then I need to change edit the configure.php file and the english.php file BACK to the old characterset.. Am I understanding this correctly???
(if I am I have a followup question)
IF I need to convert, does the upgrade process upgrade the data and tables, or do I still need to run your conversion script??? (the one that's in the free downloads section)
-
Re: ability to define DB_CHARSET ?
Choosing your character set is *your* job, not Zen Cart's job. The zc_install upgrade process DOES NOT change your character set. That's up to you.
If your existing database is NOT in utf-8 then you'll need to change your Zen Cart language files and configure.php to use whatever character set you're using with your database.
For new installs, it's best to use utf-8 because it's generally more globally compatible and most hosts use it by default now, so a new store should also use it by default. That's why the Zen Cart distribution files are set to use utf-8 by default.
Again, if *you* can't or don't want to use utf8 for whatever reason (including because you're upgrading a store whose data is NOT already utf8) then you need to change the Zen Cart code/files/etc to NOT use utf8.
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
Choosing your character set is *your* job, not Zen Cart's job. The zc_install upgrade process DOES NOT change your character set. That's up to you.
okay.. got it... I will run the database upgrade script I used before..
Quote:
Originally Posted by
DrByte
If your existing database is NOT in utf-8 then you'll need to change your Zen Cart language files and configure.php to use whatever character set you're using with your database.
understood..:yes:
Quote:
Originally Posted by
DrByte
For new installs, it's best to use utf-8 because it's generally more globally compatible and most hosts use it by default now, so a new store should also use it by default. That's why the Zen Cart distribution files are set to use utf-8 by default.
Again, if *you* can't or don't want to use utf8 for whatever reason (including because you're upgrading a store whose data is NOT already utf8) then you need to change the Zen Cart code/files/etc to NOT use utf8.
understood..:yes:
-
Re: ability to define DB_CHARSET ?
Hello,
I have a problem with my Zencart 1.3.9h. I installed Zencart with UTF8 coding. The same with some people here, my Zencart could display Japanese characters correctly but in the MySQL DB, the characters show a mess. After I installed the following files, MySQL DB and Zencart shop both can display Japanese Characters correctly.
/includes/extra_configures/my_db_charset.php
/admin/includes/extra_configures/my_db_charset.php
However, a new issue happens. When I want to create a new account from shop page or input product information from admin page, the character become a mess. How can I resolve the problem?
I think I have the same problem with Nurapipi here
http://www.zen-cart.com/showthread.p...r-v1-3-x/page2
It seems Nurapipi resolved the problem by changing to another server, but is there any other way to resolve the issue? Because there are so many hosting service in the Internet and it is difficult to try all of them.
Thank you.
-
Re: ability to define DB_CHARSET ?
Quote:
Originally Posted by
DrByte
Create a new file for it:
/includes/extra_configures/my_db_charset.php
Code:
<?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.
Thank you double for me too, DrByte.
version 1.5.1
I have been reviewing recent upgrade from 1.3.8 to 1.5.1 completed by host, and had many descriptions with ? inside black diamonds scattered on site. This conflict in Charset caused some product pages to go blank in name and description fields in admin side.
Site now is without strange characters and admin side is ready for editing old product descriptions if needed.