Forums

UTF8 in database

Le Pache 18 Mar, 2019
Hi everybody,

I'm having a problem with the UTF8 characters saved in database. They are in UTF8 in sended mail. That is what the debugger shows :

Array
(
    [option] => com_chronoforms6
    [chronoform] => ...
    [event] => submit
    [1] => Array
        (
            [0] => Est agréable à vivre
        )

[save_data12] => Array
        (
            [data] => Array
                (
                    [created] => 2019-03-18 12:31:07
                    [user_id] => 0
                    [ip_address] => ...
                    [1] => ["Est agr\u00e9able \u00e0 vivre"]

[email8] => Array
        (
            [recipients] => Array
                (
                    [0] => xxx@xxx.com
                )

            [subject] => ...
            [body] => 
<table width="100%" cellpadding="5" cellspacing="3" border="0" class="ui table"><tr><td width="30%" valign="top" align="right"><strong>1 - ....</strong></td><td width="70%" valign="top" align="left">Est agréable à vivre</td></tr><tr><td width="30%" valign="top" align="right">
Thanks for help !
Max_admin 18 Mar, 2019
How is the data displayed in the table manager in the admin area ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
healyhatman 19 Mar, 2019
https://stackoverflow.com/questions/202205/how-to-make-mysql-handle-utf-8-properly
Le Pache 19 Mar, 2019
In admin area, data are displayed like this :
Est agr\u00e9able \u00e0 vivre
Thank you for your help Max
Le Pache 19 Mar, 2019
Thanks healyhatman.
I've changed my data incoding in phpmyadmin from utf8_general_ci to utf8mb4_general_ci and tried utf8mb4_unicode_ci also, but it does not change anything.
healyhatman 19 Mar, 2019
What happens if you use
echo utf_encode($this->data("name_of_your_form_field"));
In a PHP block? Or utf_decode?

Also does https://www.toptal.com/php/a-utf-8-primer-for-php-and-mysql help
Le Pache 19 Mar, 2019
The variable itself seems fine :
Echo : Est agréable à vivre
Encode : Est agréable à vivre
Decode : Est agr�able � vivre

I don't have control over the database parameters, but the fields are UTF-8. The rest of joomla works with the same database link, so I guess the parameters are fine.

Please note that in my Debugger output, the first block is fine while the second isn't. Is that a database read, or the data as it is to be sent to the DB ?
Max_admin 25 Mar, 2019
1 Likes
I think this is a bug with the latest one or two updates but a fix should be available in the next update!

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Le Pache 04 Apr, 2019
Thanks Max for the update. It's ok now for UTF8.
I still have a problem : a SQL 1064 error message. Could it be possible that ( or / in text field produce this error ?
GreyHead 04 Apr, 2019
Hi LePache,

I think a 1064 message is a syntax error - if you add a Debugger to your form temporarily you should see the SQL query that is being created. That will help you pin down where the error is occurring.

Bob
healyhatman 04 Apr, 2019
Unfortunately v6 data actions aren't caught and cause a fatal error so you won't see any debug or anything. Which I've requested Max change.
GreyHead 04 Apr, 2019
Hi healyhatman,

Hmmm . . . does the Joomla! debugger show the query? That might help.

Bob
Le Pache 05 Apr, 2019
Hi everybody,
I still have this red message of SQL error. And of course,I can't see the debugger when it occurs.
the form does not pass the first time and then passes with the same data once next.
The error is always of the same type. A field (checkbox or radio) then a number between ' ' (which is not a data entered in the form) then the contents of other fields (the last is cut).
I do not understand at all what can generate this error.I removed all the special characters from the options of chechboxes or radios ...
Please help ! My client becomes crazy...

Le Pache 11 Apr, 2019
Answer
1 Likes
I finally found the cause of the SQL error.
WARNING: the name of the fields must not start with a number, which is not specified in CF6!
And since the name of the field is automatically generated with the label, if it starts with a number (eg the number of the question), this causes SQL errors!
It would be nice to test (as in CF5) that the name does not start with a number ...
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount

{item:title} {images:#}