How to return all the tags from a specific vocabulary for the current node I am trying to return all tags from a vocabulary but the code below keeps giving me error.

$vid = 1;  
$nid = arg(1);

$getterms = db_query('SELECT t.tid, t.* FROM {taxonomy_term_data} t INNER JOIN {taxonomy_index} r ON r.tid = t.tid WHERE t.vid = :vid AND r.nid = :node_nid ORDER BY weight', array(':vid' =&gt; $vid, ':node_nid' =&gt; $nid-&gt;nid));


I am getting 2 errors:


Notice: Trying to get property of non-object in eval() ...
Recoverable fatal error: Object of class DatabaseStatementBase could not be converted to string in eval() ...
arg() returns a string so $nid is not an object. You're currently adding your :node_nid database condition with a value of $nid-&gt;nid, when you should just be using $nid:

$vid = 1;  
$nid = arg(1);

// Updated as per comments below
$sql = 'SELECT t.name FROM {taxonomy_term_data} t INNER JOIN {taxonomy_index} r ON r.tid = t.tid WHERE t.vid = :vid AND r.nid = :node_nid ORDER BY weight';
$args = array(':vid' =&gt; $vid, ':node_nid' =&gt; $nid);

$terms = db_query($sql, $args)-&gt;fetchCol();
$comma_separated = implode(', ', $terms);


If you want to load the node object related to the current path then you can use menu_get_object(); then you can access the nid as part of the object:

$node = menu_get_object();
$nid = $node-&gt;nid;


But I suspect that will be overkill as you only really need the $nid, and not the full node object for your query.