To test this, just put the code you posted in a plugin that is fired on the global_start hook, then put $yourdkp in your postbit template (or postbit_legacy if that's the one you're using).
But
please sanitize your database inputs. Do you know what would happen if someone entered this as their DKP userid?
[sql]joeblow'; drop table eqdkp_members; --[/sql]
At least do this before your query.
PHP Code:
$dkpname = mysql_real_escape_string($dkpname);