[SOLVED][Drupal Errors] Fatal error: Cannot redeclare getnodecount() (previously declared in

By | 12th Dec 2012 | 1 min read

Many Drupal users have encountered a message similar to Fatal error: Cannot redeclare getnodecount() (previously declared in /var/www/sites/site.org/htdocs/includes/common.inc(1685) : eval()'d code:3) in /var/www/sites/site.org/htdocs/includes/common.inc(1685) : eval()'d code on line 9" If you are faced with an error of similar type then read on to find out more about the issue.

This error is likely to happen if PHP code has been inserted into a block body in the body of a node. Typical cases would be examples of Drupal code attached to Drupal tutorials or PHP tutorials. This code will usually redeclare the function in question causing the conflict. Follow the steps below to fix it.

  • You will have to perform a search in the node_revisions table of your Drupal database to find the node which contains the code in question using the following MySQL query
    SELECT nid
    FROM node_revisions
    WHERE body LIKE '%getnodecount%';
  • Use the nodes found in the result from the query via Drupal's admin to see that the function is declared only once

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.