Accents and non-English characters, such as ñ to php

Issues related to forms.
Post Reply
sbrantes
Posts: 7
Joined: Wed Mar 09, 2016 2:58 pm

Accents and non-English characters, such as ñ to php

Post by sbrantes » Wed Mar 09, 2016 3:19 pm

Forms are very easy to do and customizable. I created al form for people from many countries. Need to have their names perfectly wrote in a MySQL DB. Despite of UFT-8 are well defined at inspector at Quick'nEWB an well specified in collation columns at phpMy admin tables, all final registries that contains ñ or accents become changed. How can I fix this?
Many thanks in advance

User avatar
Pablo
Site Admin
Posts: 2637
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

Re: Accents and non-English characters, such as ñ to php

Post by Pablo » Wed Mar 09, 2016 9:30 pm

Did you also set 'Accept characterset' to 'UTF8' in the form properties?

sbrantes
Posts: 7
Joined: Wed Mar 09, 2016 2:58 pm

Re: Accents and non-English characters, such as ñ to php

Post by sbrantes » Thu Mar 10, 2016 1:23 pm

Yes, I did. In the Property inspector section Quick'nWM shows specific fields for that in page properties and form properties also.
I configured both for charset utf-8.

Then Iwent to phpMy Admin at cpanel. Switched to UTF-8 every charset that found, for database, table and columns, but new registries still have wrong characters replacing ñ or accents.

Some posts in other forums recommend
For HTML content:
Put in the <head> of all HTML files:
<Meta http-equiv = "Content-type" content = "text / html; charset = utf-8" />
Content type PHP
And in the purely PHP (showing XML, AJAX calls, APIs ...) put the code:
header ( "Content-Type: text / html; charset = utf-8");

When creating PHP connection with MySQL, sends this query right after the connection:
mysql_query ("SET NAMES 'utf8'");
(For MySQLi write $ accents = $ db-> query ("SET NAMES 'utf8'").
  It sounds logical but do not know exactly how to do that.
Creating connection is an automated process in Quick'n, Where should add these codes?

User avatar
Pablo
Site Admin
Posts: 2637
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

Re: Accents and non-English characters, such as ñ to php

Post by Pablo » Thu Mar 10, 2016 6:30 pm

This code can only be added if write the form processing script yourself.
It's not possible to modify the form processor script because Quick 'n Easy Web Builder is not a code editor.

sbrantes
Posts: 7
Joined: Wed Mar 09, 2016 2:58 pm

Re: Accents and non-English characters, such as ñ to php

Post by sbrantes » Tue Mar 15, 2016 4:33 am

Solved
1.- Turn to an utf8 charset every option in phpMyadmin (usually utf8_general_ci), at "Operations" either for the database, tables and columns.
2.- Build the form in quickn'easyWB and add the meta:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
in the box available as [User defined] at the [Meta Tags] menu on the property inspector. (As shown in the picture1).
3.- Upload the form built in quickn'easyWB.
4.- Open the next two files with an code editor (FLOW for mac users or TEXTWRANGLER) or similar.
5.- Look for the hidden file .htaccess where your form is uploaded. Edit writing one line:
AddDefaultCharset utf-8
then save.
6.- The second file to be opened is your form xxxx.php. Add this line:
mysql_set_charset('utf8');
Must be placed in a line after the "connect" and before the "mysql_query create database..." as shown in the line 218 at the picture2 as example.
That is all.
Thanks to [support]. His suggestion gave the idea to edit the code. Anyway surely our good friend De Pablo can incorporate this as an option in future versions of quicken'&EWB.
If anyone knows less labor-intensive ways to make databases show eñes, á, é, ó or ü, â, à or similar, as they are, rather than rare characters, it would be good to share.
Best regards
Sergio

User avatar
Pablo
Site Admin
Posts: 2637
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

Re: Accents and non-English characters, such as ñ to php

Post by Pablo » Tue Mar 15, 2016 7:14 am

Thanks for the solution!
Note that step 2 is not necessary. You can set the character set in the page properties.

I will try to add mysql_set_charset('utf8'); in a future update.
Note however that I first have to investigate the side effects (if any). I do not want existing forms to stop working because of this.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests