开发者

Why does this query work inside a block but not inside custom Panel content?

开发者 https://www.devze.com 2023-01-22 23:27 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号