Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ellisboal on
When I create a node page containing a php function definition ( hello_world() in the example below ) I get the following error message, even though there is no function of that name in my common.inc file. The same thing happens no matter what I name the function. Why?
Fatal error: Cannot redeclare hello_world() (previously declared in /home/labornot/public_html/includes/common.inc(1816) : eval()'d code:3) in /home/labornot/public_html/includes/common.inc(1816) : eval()'d code on line 2
Thank you.
Comments
I'm getting the same error.
I'm getting the same error. It happens everytime I try to run cron jobs.
No matter what I name any function I declare in a content page using PHP, I get the following message (first function in the content page is 'getmatchsessionuid'):
Fatal error: Cannot redeclare getmatchsessionuid() (previously declared in /includes/common.inc(1342) : eval()'d code:57) in /includes/common.inc(1342) : eval()'d code on line 65
Any ideas? :D
Thanks!
same error in template.php
I now also get this error, when I try to redefine a function in template.php (in order te override the function from a module). There must be a command to unregister a function, so that you can place the right before you declare the function?
Same Error In Nodes With PHP Functions Used More Than Once
I receive this same error if I use the same function name in two different nodes. For example if I have a function called DisplayRecord in node/136 and try to use that same function name again in node/467 I will receive this error any time I try to run a cron job.
The only solutions I have found are to disable PHP filter module or be very careful to name all my functions differently from page to page. Disabling PHP filter is not reasonable option and renaming all my functions is very time consuming.
It looks like this problem has been around for a while now. Any fixes or ideas would be welcome.
Scott Idem
--
Edit
I just realized I posted a reply to Drupal 4.6.x. I am currently using Drupal 6.9.
A workaround could be like this
A workaround could be like this:
Tracking
tracking...
Possible causes and fixes
Possible causes and fixes at http://drupal.org/node/72099