diff --git a/htdocs/user/api_token/card.php b/htdocs/user/api_token/card.php index 2cba28f82d6..d342a0e358f 100644 --- a/htdocs/user/api_token/card.php +++ b/htdocs/user/api_token/card.php @@ -287,8 +287,10 @@ if (empty($reshook)) { $nbtotalofrecords = $objforcount->nbtotalofrecords; } else { dol_print_error($db); + $error++; } - if (!isset($nbtotalofrecords) || $nbtotalofrecords > 0) { + + if (isset($nbtotalofrecords) && $nbtotalofrecords > 0) { setEventMessages($langs->trans("ErrorFieldExist", $langs->transnoentitiesnoconv("ApiToken")), null, 'errors'); $action = 'create'; $error++;