Okay, I'm very confused. I had this code in my hook_block under the view operation and it worked fine. I decide to put the query in its own function to pretty up the code and it stops working.

function _module_whatever($delta){
if ($delta == 3){
    	$type1 = 'looking';	
    	$field_name = 'field_lookingreference';
    	$row[] = array('General', 'Specific', 'Description', 'Specific');
    	
	}
	elseif ($delta == 4){
	   	$row[] = array('General', 'Specific', 'Description', 'Specific');
    	$type1 = 'offering';	
    	$field_name = 'field_offeringreference';
	}
	
	$sql = "SELECT n.nid, t.tid  FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid WHERE n.uid = %d AND n.type = '%s' ORDER BY n.nid";
	$result = db_query(db_rewrite_sql($sql), $user->uid, $type1);	
    
    while($data = db_fetch_object($result)) {
//Never reaches here. For whatever reason, the $data is remaining null and the db_fetch_object is not working.
..}
}

The $data = db_fetch_object($result) is coming up null. I've run dsm($result) and it's given me objects, but the function is not working. dsm($data) is NULL.

So, so, so very confused.

Comments

nevets’s picture

Your code is missing a global $user; so the query returns no results.

Retsage’s picture

Oh.

Wow.

Time to face-plant into a wall. :p

Thanks a lot, Nevets.