Ciao,
nella documentazione di count() (http://php.net/manual/en/function.count.php)
puoi ben leggere:
Return Values:
Returns the number of elements in var. If var is not an array or an object with implemented Countable interface, 1 will be returned.. There is one exception, if var is NULL, 0 will be returned.
ora sei proprio sicuro sicuro che $record sia 2??
metti un echo $record subito dopo $record = count($risultati);
perché forse il rpoblema è in $risultati che non è Countable e allora ti restituisce 1...