Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Weird separator causes problems in Joomla

More
4 years 9 months ago #6264 by webdev-ae
I have a form with a checkbox group.
Here is what I see in the database:
select F69 , F70 , F71 , F72 from cms_visforms_6;
Code:
+--------------------------+------------+------------+--------------+ | F69 | F70 | F71 | F72 | +--------------------------+------------+------------+--------------+ | yves.geunes@aeronomie.be | 2017-07-24 | 2019-07-31 | 11 , 21 , 12 | +--------------------------+------------+------------+--------------+

I tried to access the data using the joomla API:
Code:
$query="select F69 as mail, F70 as startdate, F71 as enddate, F72 as days from cms_visforms_6 where F69='$mail'"; $db->setQuery($query); $result = $db->loadAssocList(); error_log(print_r($result,true)); file_put_contents("PARTTIME.TXT",print_r($result,true),FILE_APPEND);
The error_log showed:
Code:
[0] => Array\n (\n [mail] => yves.geunes@aeronomie.be\n [startdate] => 2017-07-24\n [endd ate] => 2019-07-31\n [days] => 11
The file pARTTIME.TXT showed me:
Code:
[0] => Array ( [mail] => yves.geunes@aeronomie.be [startdate] => 2017-07-24 [enddate] => 2019-07-31 [days] => 11 )
When I use mysql CLI I see:
Code:
+--------------------------+------------+------------+--------------+ | mail | startdate | enddate | days | +--------------------------+------------+------------+--------------+ | yves.geunes@aeronomie.be | 2017-07-24 | 2019-07-31 | 11 , 21 , 12 | +--------------------------+------------+------------+--------------+
Only when I redirected the output of the mysql command to a file, I found out the truth:
Code:
mail startdate enddate days yves.geunes@aeronomie.be 2017-07-24 2019-07-31 11\0, 21\0, 12

I understand that a \0 character is used as separator, but it is not very clear, and Joomla stumbled on it. To obtain my data, the query had to be modified to:
Code:
$query="select F69 as mail, F70 as startdate, F71 as enddate, replace(F72,'\0','') as days from cms_visforms_6 where F69='$mail'";

More
4 years 9 months ago #6265 by Administrator AV
Replied by Administrator AV on topic Weird separator causes problems in Joomla
Hi,
thanks for your post!

Actually this is not a weird separator but the null byte.

As visForms supports multi select in checkbox groups and in selects and any selected options must be stored in the database and the option value, which is actually stored might contain almost any character. Using the null byte in order to separate the stored otpion values is very common way to handle such problems.

So this is the intended behavior and visForms does handle the null byte properly in its own code. But if you access the database not throughout the visForms code you have to handle it by yourself.

Thanks for sharing this information, which might be helpful for other users who want to access the visForms tables directly.

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum