Fatal error 500 -Cannot redeclare getUserId_2()-

jhaviro 29 Nov, 2016
Hello!

I get this error:

Fatal error: Cannot redeclare getUserId_2() (previously declared in xxxxxxxxxxxxxxxxxx/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code:19) in xxxxxxxxxxxxxx/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 28

This error occurs when I try to edit a form previously saved in DB but only happens with new forms created And it happens to any user who is not an administrator (any group except admin). To explain this should explain the whole application, but it is difficult. If you need to login as Administrator to my site, please send me an email where I can attach the data.

Version of php 5.4.1
GreyHead 29 Nov, 2016
Hi jhaviro,

That is coming from Custom Code in your form - what do you have on those lines 19 & 28? (It may be from two different Custom Code actions).

Bob
jhaviro 29 Nov, 2016
This is the function in lines 19 to 28



function getUserId_2($username)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__users'))
->where($db->quoteName('name') . ' = ' . $db->quote($username));
$db->setQuery($query, 0, 1);
return $db->loadResult();
}
jhaviro 29 Nov, 2016



function getUserId_2($username)
{
    $db = JFactory::getDbo();
    $query = $db->getQuery(true)
        ->select($db->quoteName('id'))	
        ->from($db->quoteName('#__users'))
        ->where($db->quoteName('name') . ' = ' . $db->quote($username));
    $db->setQuery($query, 0, 1);
    return $db->loadResult();
}


Sorry
jhaviro 29 Nov, 2016
I think I've found the error. My code is not correct. When editing the form I am asking for a data that does not exist in the user. Sorry. When I check it I send the result. Thank you very much. I will publish the result shortly.
jhaviro 29 Nov, 2016
In effect, my code is correct but an ID is missing within a group of users. It's just a matter of updating the tables with the correct data. Sorry for the inconvenience and thank you very much for your support.
This topic is locked and no more replies can be posted.