How do I get the uid of a node?
That should work. Try making sure that you have a properly loaded node object.

$node = node_load('NID');
echo $node-&gt;uid;


It is possible that if the node was created by an anonymous user that the $uid would be zero and thus wouldn't print.