I use the PHP form plugin and I want to compare the # records in two tables before form submission and display an error text. The user has to redo the input field(s) to prevent the error.
I set the plug-in to run 'onAfterProcess' with this code
$db = JFactory::getDbo();
$query =$db->getQuery(true);
$query = "SELECT COUNT(*) FROM table_1";
$db->setQuery($query);
$a = $db->loadResult();
$query =$db->getQuery(true);
$query = "SELECT COUNT(*) FROM table_2";
$db->setQuery($query);
$b = $db->loadResult();
if ($a !== $b) echo "ERROR !";
But than I always get this error: SyntaxError: Unexpected token F in JSON at position 1
Now I am lost here, what to do to make it work??
I set the plug-in to run 'onAfterProcess' with this code
$db = JFactory::getDbo();
$query =$db->getQuery(true);
$query = "SELECT COUNT(*) FROM table_1";
$db->setQuery($query);
$a = $db->loadResult();
$query =$db->getQuery(true);
$query = "SELECT COUNT(*) FROM table_2";
$db->setQuery($query);
$b = $db->loadResult();
if ($a !== $b) echo "ERROR !";
But than I always get this error: SyntaxError: Unexpected token F in JSON at position 1
Now I am lost here, what to do to make it work??
Last edited: