By bmblack on
I was trying to add a new block to my website. I copied the following code from this site: http://drupal.org/node/148911 and pasted it into a new php block.
As soon as I enabled the new block, my page went blank and i got the following error!
Fatal error: Call to undefined function db_num_rows() in public_html/includes/common.inc(1685) : eval()'d code on line 9
I can't get back into my admin to delete the block, every page I try to go to, I get that message! Please tell me this is something I can fix!
<?php
// Count users with activity in the past defined period.
$interval = time() - 900;
// Perform database queries to gather online user lists. We use s.timestamp
// rather than u.access because it is much faster is much faster..
$anonymous_count = sess_count($interval);
$authenticated_users = db_query('SELECT u.uid, u.name FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
$authenticated_count = db_num_rows($authenticated_users);
// Format the output with proper grammar.
if ($anonymous_count == 1 && $authenticated_count == 1) {
$output = t('There is currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
}
else {
$output = t('There are currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
}
echo $output;
?>
Comments
Delete the block in your site's DB
Access the db for the site.
Find the block in question in the blocks table and delete it.
Your site will be ok.
As for the code, beats me.
If you used drupal 6: you
If you used drupal 6:
replace "db_num_rows($authenticated_users)" with "db_affected_rows()".
Edit box's content in database table "boxes", body field.
Whew, worked. Thank you!
Whew, worked. Thank you!