php and event switcher does not work properly

Resolve an event switcher not working due to incorrect PHP logic.

Overview

The issue was caused by an incorrect logical operator in a custom PHP code snippet within CF.
Update the PHP code by changing the logical operator from 'and' to 'or' to ensure the query functions correctly, then verify the count value to confirm the fix.

Answered
ChronoForms v6
sa samir1903 23 Feb, 2019
this new version bugs bugs and bugs

php16
$app =& JFactory::getApplication();
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `os5pk_chronoforms_data_xxxx`
WHERE `no_DI` = '{$this->data['no_DI']}' or `correo` = '{$this->data['correo']}';
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > 0 ) {
return 'registered_ID';
} else {
return 'look_codigo';
}
event swither data provider
{var:php16}
switches
registered_ID and look_codigo
this php return in debug always look codigo

i wanted to upload images here but i think there is a bug in forum as well i couldnt upload 🤣
Max_admin Max_admin 23 Feb, 2019
Hi samir,

Please test with the new update ?

Also you can modify your code to do a quick test, use this:
pr($count);
to check the count value directly!

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sa samir1903 23 Feb, 2019
Answer
right new version looks better
before ,it returned 0 therefore event switcher worked correct

however problem was in php

it appearded "and parameter" instead of "or parameter", even i am sure i put "or", this where i copied and pasted to the forum.

now changed and to or, it returned 1

so bug is gone
thanks
This topic is locked and no more replies can be posted.