By hexa on
I made this simple snippet using Drupal 5 api functions.
It works as expected when i'm logged in as admin, but db_quers returns FALSE when anonymous or any other user accesses this block. How can i make it work for everybody?
Please help.:-)
<?php
$SQL = 'SELECT * FROM {radio_playlist} ORDER BY lastplayed DESC LIMIT 2';
$r = db_query(db_rewrite_sql($SQL));
$i = '1';
if ($r != FALSE) {
echo 'Now playing:<br>';
while ( $song = db_fetch_object($r)) {
if ($i == '2') {
echo 'Previusly played:<br>';
}
$i++;
if ($song->title == '') {
echo '<a href="http://radio.isg.si/node/' . $song->vid . '">"This song :-)</a><br>';
} else {
echo '<a href="http://radio.isg.si/node/' . $song->vid . '">"' . $song->title . '</a><br>';
} //end if
} //end while
} //end if$r != FALSE) {
?>
Comments
Fixed after i saw this
Fixed after i saw this error:
I just don't use db_rewrite_sql() for this SQL anymore.
db_rewrite_sql()
If you are using any access control modules (OG, TAC, TAC Lite, etc) then you'll want to keep the db_rewrite_sql() in. Otherwise dropping it won't be a problem.
However, the underlying cause WHERE ((n.moderate != 1 OR n.uid = 0)) is more of a concern for you. Why? Well, some module you have installed is doing SQL rewriting and I therefore assume you do have some sort of access control module in place.
The problem here is simple. The "moderate" field in {node} was dropped in Drupal 5. The fact that a module is putting that in means either a) you have somehow managed to install a Drupal 4.7 onto your Drupal 5 or, more likley, b) you are using a module that has a Drupal 5 problem. Can you give us a list of modules you are using?
Modr8 5.x-2.2 Easy,
Modr8 5.x-2.2 Easy, dedicated moderation of content
As for radio_playlist table, it's managed outside of Drupal.