Why does the following query work within a Drupal Block, but not when part of a "custom content" in a pane within a Panels Page? It gives an error saying to check the syntax of the query near "AND node.type in....". Also, if I put it in a Block then display that Block inside a Panels Page, it works just fine. So while I've got this working... I really want to know why it wouldn't work when placed directly in the Panel content.
<?php
global $user;
if($user->uid) {
$result = db_query("Select COUNT(node.nid) from {node}
LEFT JOIN {flag_content} flag_content_node
ON node.nid = flag_content_node.content_id AND
flag_content_node.fid = 7
where node.uid = %d AND node.type in ('node_type') A开发者_开发技巧ND
(flag_content_node.uid IS NULL)", $user->uid);
$item_count = db_result($result);
print $item_count;
}?>
There's probably something wrong with your parameter to the query, because it's there that it goes wrong. Perhaps if $user->uid
is null? Would it then insert '' into the query instead of the "%d"? That would seem odd.
It would also imply that you're not logged in.
No, that can't be, as you check that $user->uid
is true, first.
精彩评论