Problem mit Access Controll
Eingetragen von hijacker (13)
am 09.12.2008 - 17:43 Uhr in
am 09.12.2008 - 17:43 Uhr in
Hallo,
seit ich die Module ACL, Content Access und Forum Access installiert habe, funktioniert folgender Code nicht mehr
<h2 class="title"> </h2>
<?php
$sql = "SELECT * FROM {node} WHERE type = 'showcase' AND status = 1";
$sqlcount = "SELECT Count(nid) AS cnt FROM {node} WHERE type = 'showcase' AND status = 1";
$result = db_query(db_rewrite_sql($sql));
$rescount = db_query(db_rewrite_sql($sqlcount));
if (!$result){
print 'Kein Schaufensterinhalt gefunden.';
} else {
$today = idate("z"); //day of the year
$count = db_fetch_object($rescount)->cnt;
$shownum = $today % $count;
$i = 0;
while ($data = db_fetch_object($result)) {
if ($i == $shownum){
$node = node_load($data->nid);
print '<h3>'.$node->title.'</h3>'.'<br>';
print $node->body;
break;
}
$i++;
}
}
?>
Ich bekomme folgende Fehlermeldung:
* user warning: Unknown column 'n.nid' in 'on clause' query: SELECT * FROM drupal_node INNER JOIN drupal_node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid') OR (na.gid = 1 AND na.realm = 'forum_access'))) AND ( type = 'showcase' AND status = 1) in /var/www/web65/html/ffw/includes/common.inc(1547) : eval()'d code on line 5.
* user warning: Column 'nid' in field list is ambiguous query: SELECT Count(nid) AS cnt FROM drupal_node INNER JOIN drupal_node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid') OR (na.gid = 1 AND na.realm = 'forum_access'))) AND ( type = 'showcase' AND status = 1) in /var/www/web65/html/ffw/includes/common.inc(1547) : eval()'d code on line 6.
Hängt das an meinem Select oder kann das noch ein Fehler der Module sein, die sich noch im Beta Status befinden?
Vielen Dank
- Anmelden oder Registrieren um Kommentare zu schreiben
So sollte es klappen $sql =
am 11.12.2008 - 12:50 Uhr
So sollte es klappen
$sql = "SELECT * FROM {node} n WHERE type = 'showcase' AND status = 1";
$sqlcount = "SELECT Count(nid) AS cnt FROM {node} n WHERE type = 'showcase' AND status = 1";
?>
Jep, den Rest einfach gleich lassen....
--------------
Blog www.freeblogger.org: Deutscher IRC-Channel: irc.freenode.net #drupal.de ... Jabber-me: dwehner@im.calug.deXING
danke für die
am 11.12.2008 - 15:36 Uhr
danke für die Antwort.
Leider bekomme ich jetzt folgende Fehlermeldung:
user warning: Column 'nid' in field list is ambiguous query: SELECT Count(nid) AS cnt FROM drupal_node n INNER JOIN drupal_node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid') OR (na.gid = 1 AND na.realm = 'forum_access'))) AND ( type = 'showcase' AND status = 1) in /var/www/web65/html/ffw/includes/common.inc(1547) : eval()'d code on line 8.
warning: Division by zero in /var/www/web65/html/ffw/includes/common.inc(1547) : eval()'d code on line 15.
Ich vermute mal die Division
am 11.12.2008 - 17:26 Uhr
Ich vermute mal die Division by zero kommt hiervon:
$shownum = $today % $count;
Warum machst du sowas nicht als View? PHP-Snippets sind nicht das optimale für Queries. Wenn schon mit eigenen Queries, dann ab damit in ein Modul.
vg
--
md - DrupalCenter.de
mdwp* :: Drupal Consulting
vg
md - DrupalCenter.de
mdwp* Drupal Consulting & Services
division by zero hab ich
am 11.12.2008 - 17:46 Uhr
division by zero hab ich behoben durch ein if ($count != 0)...aber die andere Fehlermeldung bleibt.
user warning: Column 'nid' in field list is ambiguous query: SELECT Count(nid) AS cnt FROM drupal_node n INNER JOIN drupal_node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid') OR (na.gid = 1 AND na.realm = 'forum_access'))) AND ( type = 'showcase' AND status = 1) in /var/www/web65/html/ffw/includes/common.inc(1547) : eval()'d code on line 8.