The returned result of a db query is a result set resource, and not an actual integer, string or whatever is stored in the database. That is assuming $db is the result of something like mysqli::__construct().
If $db is a class you or someone else wrote, it's of course entirely possible that the returned value is an int, string or array, but since I've not seen any such code, I'm rolling with my first assumption.
$result = $db->query();
// $result is either a result set resource, or if something went wrong, boolean false
if ($result === false) {
echo $db->errno() . ": " . $db->error();
/* exit; if you want your script to stop running here. But you might want to let the script
complete without this query.
}
else {
// Get the next row from the result set, and advance its internal pointer
/* If no rows where returned, this evaluates to false the first time, so you've
allready dealt with an empty result set */
while ($row = $result->fetch_assoc()) {
echo $row['someFieldNameFromShareholderNames'];
}
}