Forum support

We provide good documentation for our free Joomla! extensions, including online documentatation directly in the administraton interface. If you need further individuel help with our free Joomla! extensions, you can subscribe for our payed support forum. Please apply for the paid forum support here and log in with the user id of the user with whom you have purchased the forum support.

Forum Support is free as long as you have an active Visforms Subscription or an active Subscription for the Bootstrap Carousel. Please just log in with your subscription user id.

Read-only use of the forums is free for everybody.

Topic-icon Weird separator causes problems in Joomla

More
5 months 5 days 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;
+--------------------------+------------+------------+--------------+
| 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:
$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:
[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:
[0] => Array
        (
            [mail] => yves.geunes@aeronomie.be
            [startdate] => 2017-07-24
            [enddate] => 2019-07-31
            [days] => 11
        )
When I use mysql CLI I see:
+--------------------------+------------+------------+--------------+
| 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:
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:
$query="select F69 as mail, F70 as startdate, F71 as enddate, replace(F72,'\0','') as days from cms_visforms_6 where F69='$mail'";

Please Log in or Create an account to join the conversation.

More
5 months 5 days ago #6265 by Administrator
Replied by Administrator 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

-- Visforms Developer --

I helped you? The best way to thank me is to post a review on Joomla! Extensions Directory or to use the donate button to the right and make a donation. :)

Always consult our documentations before asking a question on our forum, the answer is most probably there. ;)

Konnte ich dir helfen? Die beste Art mir zu danken ist es, ein Review auf Joomla! Extensions Directory zu schreiben oder den Spendenbutton rechts zu verwenden, um mir eine Spende zukommen zu lassen. :)

Bitte konsultiere immer zuerst unsere Dokumentationen bevor du eine Frage im Forum stellst, die Antwort ist bestimmt da. ;)

Enjoy Joomla!

Please Log in or Create an account to join the conversation.

Moderators: Administrator