diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index 8232da94989..e3925ddb232 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -410,7 +410,7 @@ else if ($id || $ref)
// Ref
print '
| '.$langs->trans("Ref").' | ';
print '';
- print $form->showrefnav($member,'rowid');
+ print $form->showrefnav($member,'id');
print ' |
';
// Login
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index c315939d327..20af2917fa4 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -716,7 +716,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n";
// Define $sqlstring
- $posnumstart=strpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...)
+ $posnumstart=strrpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...)
if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence';
$sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')';